home *** CD-ROM | disk | FTP | other *** search
- {$V-}
- procedure get_arg(Narg : Integer; var arg : MaxString);
- var
- cml : MaxString absolute Cseg:$80;
- CmdLine : MaxString;
- pos, last, len, i, j : Integer;
- NotFound : Boolean;
- const
- White : set of char = [' ', ^I, ','];
- begin
- CmdLine := cml + ' ';
- len := Length(CmdLine);
- last := 1;
- NotFound := false;
- pos := 1;
- While (not (CmdLine[last] in White)) and (last < len)
- do last := last+1;
- if Narg = 0 then begin
- if last = 1 then NotFound := true;
- end
- else begin
- for i := 1 to Narg do begin
- pos := last;
- While (CmdLine[pos] in White) and (pos < len)
- do pos := pos + 1;
- if pos = len then NotFound := true
- else begin
- last := pos;
- While (not (CmdLine[last] in White)) and (last < len)
- do last := last +1;
- end;
- end;
- end;
- if NotFound then arg := ''
- else begin
- j := 0;
- for i:= pos to last -1 do begin
- j := j +1;
- arg[j] := CmdLine[i];
- end;
- arg[0] := char(last - pos);
- end;
- end;
- {$V+}