Category : Pascal Source Code
Archive   : TPTSR.ZIP
Filename : CMDLN.DEM

 
Output of file : CMDLN.DEM contained in archive : TPTSR.ZIP
{
cmdln.dem
6-4-90
Demo the use of cmdln.pas

Copyright 1990
John W. Small
All rights reserved

PSW / Power SoftWare
P.O. Box 10072
McLean, Virginia 22102 8072
(703) 759-3838
}

program cmdlnDemo;
uses crt, cmdln;
var options : string;
params : CmdLnParams;
i : integer;
begin
clrscr;
if ParamCount > 0 then begin
writeln('Test the CmdLnParam object with the following command line:');
writeln;
write(' ');
for i := 0 to ParamCount do
write(ParamStr(i),' ');
writeln
end;
params.init('o:');
if boolean(params.getOption) then;
if (params.optCh <> 'o') or (length(params.optArg) = 0)
then begin
writeln('usage: cmdln -ooptions *');
writeln;
writeln('where "options" consists of the letters to look for, and');
writeln(' "*" are the command line arguments to be parsed by "options."');
writeln(' For the purposes of this test "o" switches are skipped.');
writeln;
writeln('For example, with the command line: ');
writeln;
writeln(' cmdln /oC:af:z /afnew /zC cmdfile outfile');
writeln;
writeln('the "options" string is "C:af:z", which means that this particular invocation');
writeln('of the demo will recognize "C", "a", "f" and "z" as switch options. "C" and');
writeln('"f" take arguments, which is indicated by the colon after each in the "options"');
writeln('string. Switch options are introduced by "/" or "-" in DOS. The "options"');
writeln('string is then used to parse the rest of the command line. In this case it');
writeln('recognizes "a", "f" with argument "new", "z", and "C" with argument "cmdfile."');
writeln('Notice that options taking arguments must appear last in the switch clusters.');
writeln('Run this demo with command lines similar to this example to see how it');
writeln('works. Then besure to read the notes in the interface section of cmdln.pas');
writeln('for complete instructions on how to use the CmdLnParams object. Then return');
writeln('to the source code of this demo and study how I used it. You will then be');
writeln('ready start coding with the CmdLnParams object.');
writeln;
writeln('Press "Enter" to quit.');
readln;
halt
end;
writeln;
writeln('Parse for the following options: ');
writeln;
for i := 1 to length(params.optArg) do begin
write(' ',params.optArg[i]);
if i < length(params.optArg) then
if params.optArg[i+1] = ':' then begin
inc(i);
write(' with argument')
end;
writeln
end;
writeln;
writeln('Parameters parsed as ...');
writeln;
params.init(params.optArg);
while (params.getOption <> #0) do
if params.optCh = '?' then
if params.optNot = 'o' then
params.nextCluster
else
write(' optNot: ',params.optNot)
else if length(params.optArg) > 0 then
writeln(' optCh: ',params.optCh,' optArg: ',params.optArg)
else
writeln(' optCh: ',params.optCh);
while (params.paramNo <= ParamCount) do begin
writeln('ParamNo: ',params.paramNo,
' ParamStr: ',ParamStr(params.paramNo));
inc(params.paramNo)
end;
writeln;
write('Press "Enter" to quit.');
readln
end.




  3 Responses to “Category : Pascal Source Code
Archive   : TPTSR.ZIP
Filename : CMDLN.DEM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/