mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:29:28 +02:00
+ fully implemented ParamStr and ParamCount on i8086-msdos
git-svn-id: trunk@24582 -
This commit is contained in:
parent
c1a1325a72
commit
0013186e2d
@ -173,9 +173,55 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function paramcount : longint;
|
||||
function GetCommandLine: string;
|
||||
var
|
||||
len, I: Integer;
|
||||
begin
|
||||
paramcount := 0;
|
||||
len := PFarByte(Ptr(dos_psp, $80))^;
|
||||
{$ifdef CG_BUG}
|
||||
{ doesn't work due to a code generator bug }
|
||||
SetLength(GetCommandLine, len);
|
||||
for I := 1 to len do
|
||||
GetCommandLine[I] := PFarChar(Ptr(dos_psp, $80 + I))^;
|
||||
{$else CG_BUG}
|
||||
GetCommandLine := '';
|
||||
for I := 1 to len do
|
||||
GetCommandLine := GetCommandLine + PFarChar(Ptr(dos_psp, $80 + I))^;
|
||||
{$endif CG_BUG}
|
||||
end;
|
||||
|
||||
|
||||
function GetArg(ArgNo: Integer; out ArgResult: string): Integer;
|
||||
var
|
||||
cmdln: string;
|
||||
I: Integer;
|
||||
InArg: Boolean;
|
||||
begin
|
||||
cmdln := GetCommandLine;
|
||||
ArgResult := '';
|
||||
I := 1;
|
||||
InArg := False;
|
||||
GetArg := 0;
|
||||
for I := 1 to Length(cmdln) do
|
||||
begin
|
||||
if not InArg and (cmdln[I] <> ' ') then
|
||||
begin
|
||||
InArg := True;
|
||||
Inc(GetArg);
|
||||
end;
|
||||
if InArg and (cmdln[I] = ' ') then
|
||||
InArg := False;
|
||||
if InArg and (GetArg = ArgNo) then
|
||||
ArgResult := ArgResult + cmdln[I];
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function paramcount : longint;
|
||||
var
|
||||
tmpstr: string;
|
||||
begin
|
||||
paramcount := GetArg(-1, tmpstr);
|
||||
end;
|
||||
|
||||
|
||||
@ -184,7 +230,7 @@ begin
|
||||
if l = 0 then
|
||||
paramstr := GetProgramName
|
||||
else
|
||||
paramstr := '';
|
||||
GetArg(l, paramstr);
|
||||
end;
|
||||
|
||||
procedure randomize;
|
||||
|
Loading…
Reference in New Issue
Block a user