[fpc-pascal] run pascal programs as scripts

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Mar 31 10:37:05 CEST 2011



On Thu, 31 Mar 2011, Darius Blaszyk wrote:

>
> On Mar 31, 2011, at 9:20 AM, michael.vancanneyt at wisa.be wrote:
>
>>
>>
>> On Thu, 31 Mar 2011, Darius Blaszyk wrote:
>>
>>> I created a patch to make instantFPC run on win32. To make the app run I
>>> implemented TProcess as windows does not understands fpexecv.  Even better
>>> would be to use TProcess for all platforms, thus removing the need of
>>> defines and we could drop the unix and windows units.
>>
>> I doubt it since execv actually replaces the current running process with the
>> indicated binary (i.e. the binary you just compiled).
>>
>>> The only script that did not work for me was exitcode.pas. I will have to look more in detail how to support this.
>>
>> That will require an alternative to fpexecv.
>
> I dont believe it was a fpexecv problem. The issue was that the command line option was not passed at all. Could well be that I'm misinterpreting the intention of how to use it.
>
> I did a: instantpfc exitcode.pas 1
>
> Assuming that the compiler options come from the shebang line and the "1" provided on the command line is passed as parameter to exitcode.exe. But as said the "1" never reached the executable. I will test mac later today to see how it should work.

I had a look at your patch.

Do yourself a favour, and use ExecuteProcess from the sysutils unit for your
Exec routine. It has all you need. The use of pipes is not needed when
running the program, it will only seriously slow the running of the program.

But do not replace the unix fpexecv call; There will always be a difference
between Windows and Unix.

The use of TProcess for the compile command is so the output of the compiler
can be hidden. For running the actual process, this is not needed.

Michael.



More information about the fpc-pascal mailing list