Sorry, again me :-)
As I understand from the docs there are no EXEC command in the GNU Pascal. Instead PExecute exists.
From the pexecutedemo.pas I understand how to call
external program but I also need to pass parameters to. I have a mess in my head with all those TString,CString and PCStrings. Could someone drop a line-two of sample code how to call the program with passing parameters.
Thanks in advance, Peter
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/
On 27 Jan 2004 at 8:50, Peter Norton wrote:
Sorry, again me :-)
As I understand from the docs there are no EXEC command in the GNU Pascal. Instead PExecute exists. From the pexecutedemo.pas I understand how to call external program but I also need to pass parameters to. I have a mess in my head with all those TString,CString and PCStrings. Could someone drop a line-two of sample code how to call the program with passing parameters.
program runit; uses dos; begin Exec ('notepad.exe', 'c:\temp\foo.txt'); end.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/
On Tue, Jan 27, 2004 at 08:50:12AM -0800, Peter Norton wrote:
Sorry, again me :-)
As I understand from the docs there are no EXEC command in the GNU Pascal. Instead PExecute exists.
From the pexecutedemo.pas I understand how to call
external program but I also need to pass parameters to. I have a mess in my head with all those TString,CString and PCStrings. Could someone drop a line-two of sample code how to call the program with passing parameters.
Thanks in advance, Peter
See the attachment for a modified pexecutedemo, which supports arguments.
There's also an `Execute' function in the run-time system, which is much easier to use. However it waits for the child process to terminate, which is not what you want if I understand correctly your reply to Chief. It executes its argument via the system shell, thus wildcard expansion and other fancy features work.
Example (assuming a POSIX-like environment):
program DirListing (Output); uses GPC; var Res: Integer;
begin Res := Execute ('echo "Pascal files in `pwd`:"; ls -l *.pas *.p'); WriteLn ('exit code: ', Res) end.
Emil
Emil Jerabek wrote:
See the attachment for a modified pexecutedemo, which supports arguments.
Thanks. If you don't mind, I'll include it with the GPC demos (slightly modified to avoid using `GetMem').
Frank