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
/
JSAGE
/
ZSUS
/
PROGPACK
/
NZ-TOOL4.LBR
/
PARAMSTR.PZS
/
PARAMSTR.PAS
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
2KB
|
35 lines
Function ParamStr(i:integer):str80;
{
Returns ith string of command. If i=0, returns command itself. If i=1 you
get the first command tail parameter, etc. This uses the multiple command
line, *not* the tbuff (hex 80 to hex ff.) Turbo Pascal itself uses tbuff+32
to tbuff+79 for its own purposes! Needed to write this function because it
is *not* in the standard lib of Turbo Pascal Version 2.
}
Var
j,j1,lcmd,lc,p : Integer;
whatsleft : str80;
cl : mclptr; { from nz-tool.box }
Begin
cl := Ptr(getmcl); { point to multiple command line, using nz-tool.box }
{ determine end of command and its offset in multiple command line }
lc := cl^.nxtchr - 1; j := lc - Ord(cl) - 3; lcmd := 0;
While (cl^.mcl[j]<>';') And (j<>0) Do Begin { back up to start of command }
j := j - 1; lcmd := lcmd + 1; End;
{ load work string with it }
For j1 := j + 1 To j + 1 + lcmd - 1 Do
whatsleft[j1 - (j + 1) + 1] := cl^.mcl[j1];
whatsleft[0] := Chr(lcmd);
p := Pos(' ',whatsleft); { locate first space }
If (i>0) And (p=0) Then whatsleft := '';
While (i<>0) And (p<>0) Do Begin { grab the ith parm }
i := i - 1; { decrement parm counter }
Delete(whatsleft,1,p); { lop off the leading parm }
p := Pos(' ',whatsleft); { locate next space }
End;
If p=0 Then { if at end, use what's left }
ParamStr := whatsleft
Else
ParamStr := Copy(whatsleft,1,p - 1); { else, what's at the beginning }
End; { of what's left }