[fpc-pascal] Re: run pascal programs as scripts
Lukasz Sokol
el.es.cr at gmail.com
Thu Mar 31 13:52:23 CEST 2011
Hi,
On 31/03/2011 10:06, Darius Blaszyk wrote:
>
> This simplifies things quite a bit. Thanks for the hint. Here's a new patch, I also added a fix for the command line options issue. Should be alright now. All examples work fine on win32.
>
> Darius
I haven't tried to run that yet, but, why not
...
{$IFNDEF MSWINDOWS}
Halt(FpExecV(Filename,p));
{$ELSE}
Halt(ExecuteProcess(Filename,CollectArgs(p)));
{$ENDIF}
...
and then in another function, CollectArgs:
function CollectArgs(p: PPChar):string;
begin
// Result := '';
Inc(p); //lose the first command-line argument with the the script filename
while (p^ <> nil) do
begin
Result := Result + ' ' + p^^;
inc(p);
end;
end;
Reason : there is no error checking nor any try/except construct involved/needed
in this code, and it seems more, hm... readable when split ?
Lukasz
More information about the fpc-pascal
mailing list