home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
TESERACT
/
TESS-025.ZIP
/
PASUTIL2.LBR
/
ARGLIST.PIN
next >
Wrap
Text File
|
1989-01-22
|
4KB
|
115 lines
{ This provides capabilities similar to argc/argv in C. You can now
read the argument list from your TURBO Pascal program. `argc' is
actually a function that returns the number of parameters on the
command line. Spaces are the separators between parameters. If the
parameter is enclosed in quotes ('), then any characters can appear.
If you want a quote, put two in the command line parameter.
Example
cmd 'this is the first' and 'this is the ''third'' argument'
This will return argc=3.
You can retrieve the arguments by calling argv(#)
Example
if the above was the command line, then the program
for i := 1 to argc do
writeln('argv(',i,') =<',argv(i),'>');
would print
argv(1) =<this is the first>
argv(2) =<and>
argv(3) =<this is the 'third' argument>
Jim Holtman
35 Dogwood Trail
Randolph, NJ 07869
(201) 361-3395
}
type
arglist_string = string[80];
const
arglist_max = 20;
arglist_number : integer = -1;
var
argvlist : array[1..arglist_max] of ^arglist_string;
function argv(num : integer) : arglist_string;
var
argument : arglist_string absolute cseg:$80;
newparm,parmline : arglist_string;
i,j : integer;
state : (leading_ws, non_quote, quoted, end_quote);
inchar : char;
procedure saveparm;
begin
if arglist_number < arglist_max then begin
arglist_number := arglist_number+1;
new(argvlist[arglist_number]);
argvlist[arglist_number]^ := newparm;
newparm := '';
end;
end;
begin
if arglist_number = -1 then begin
arglist_number := 0;
parmline := argument+' ';
state := leading_ws;
newpanto the sign bit}
s_string := current_directory+'\'+s_string;
writeln(s_string, '':(65-length(s_string)),(r2*65536.0+r1):7:
0, attribute:3);
end;
ax := $4F00; {get next}
msdos(param);
end;
ax := $1A00; {set DTA}
ds := dta_save[1];
dx := dta_save[2];
msdos(param);
end;
end;
= ofs(current_directory[1]);
ax := $4700;
msdos(param);
current_directory := '\'+pack_name(current_directory[1],64);
while (flags and carry) = 0 do begin
s_string := pack_name(file_name,sizeof(file_name));
if ((attribute and directory) <> 0) and (s_string <> '.') and (
s_string <> '..') then begin
{writeln('decending to ',s_string);}
nteger;
state : (leading_ws, non_quote, quoted, end_quote);
inchar : char;
procedure saveparm;
begin
if arglist_number < arglist_max then begin
arglist_number := arglist_number+1;
new(argvlist[arglist_number]);
argvlist[arglist_number]^ := newparm;
newparm := '';
end;
end;
begin
if arglist_number = -1 then begin
arglist_number := 0;
parmline := argument+' ';
state := leading_ws;
newpa begin
write('Pattern to search for - ');
readln(pattern);
pattern := pattern+chr(0);
recurse;
end.