home *** CD-ROM | disk | FTP | other *** search
-
- Function ParamStr(i:integer):str80;
-
- {
-
- Returns ith string of command. If i=0, returns command itself. If i=1,
- returns 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.
-
- Updated on 1/19/91 - Now using message buffer's "error address" which under
- z33+ holds address of current command.
-
- Updated on 2/23/93 - Removed an extraneous semicolon. Remember, syntax
- is:
-
- if condition then
- st1
- else
- st2;
-
- }
-
- Var
- j,p,ea : Integer;
- current : str80;
- msg : msgptr; { from nz-tool.box }
- byt : Byte;
-
- Begin
- msg := Ptr(getmsg); {get message buffer, using nz-tool.box}
- ea := msg^.eradr; {get address of current command}
- byt := Mem[ea]; j := 0; {load first byte of current command and init. j}
- While (byt <> ord(';')) And (byt <> 0) Do Begin {find end of command}
- current[j+1] := Chr(byt); {and load work string}
- j := j+1;
- byt := Mem[ea+j]; End;
- current[0] := Chr(j); {fill in command length}
- p := Pos(' ',current); {locate first space}
- If (i > 0) And (p = 0) Then current := '';
- While (i <> 0) And (p <> 0) Do Begin {grab the ith parm}
- i := i-1; {decrement parm counter}
- Delete(current,1,p); {lop off the leading parm}
- p := Pos(' ',current); {locate next space}
- End;
- If p=0 Then {if at end, use what's left}
- ParamStr := current
- Else
- ParamStr := Copy(current,1,p-1);
- {else, what's at the beginning}
- End; {of what's left}
-