Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
exec() Posted by bpajk on 21 Oct 2003 at 12:04 PM
This message was edited by bpajk at 2003-10-21 12:12:5

My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
program test;
uses dos;
begin
  swapvectors;
  exec('c:\windows\notepad.exe','');
  swapvectors;
  readln
end.



Report
Re: exec() Posted by Manning on 21 Oct 2003 at 12:26 PM
: This message was edited by bpajk at 2003-10-21 12:12:5

: My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
:
: program test;
: uses dos;
: begin
:   swapvectors;
:   exec('c:\windows\notepad.exe','');
:   swapvectors;
:   readln
: end.
: 


What flavour of FPC? If it's the GO32V2 one, you may need to use:

exec(GetEnv('COMSPEC'), '/C c:\windows\notepad.exe');

Report
Re: exec() Posted by werner02 on 22 Oct 2003 at 1:58 AM
: : This message was edited by bpajk at 2003-10-21 12:12:5

: : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
: :
: : program test;
: : uses dos;
: : begin
: :   swapvectors;
: :   exec('c:\windows\notepad.exe','');
: :   swapvectors;
: :   readln
: : end.
: : 


:
: What flavour of FPC? If it's the GO32V2 one, you may need to use:
:
:
: exec(GetEnv('COMSPEC'), '/C c:\windows\notepad.exe');
: 

:
:///////////////////////////////////////////////////////////////////
Try is one:
: program test;
: uses dos;
: begin

: command := '/c' + 'windows\notepad.exe' ;
: swapvectors;
: exec(getenv('COMSPEC'), command);
: swapvectors;
:////////////////////////////////////////////////////////////////////

May you can help me in closing that program (written in perl)
Best Regards
Werner


Report
Re: exec() Posted by Manning on 22 Oct 2003 at 5:08 AM
: : : This message was edited by bpajk at 2003-10-21 12:12:5

: : : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
: : :
: : : program test;
: : : uses dos;
: : : begin
: : :   swapvectors;
: : :   exec('c:\windows\notepad.exe','');
: : :   swapvectors;
: : :   readln
: : : end.
: : : 

:
: :
: : What flavour of FPC? If it's the GO32V2 one, you may need to use:
: :
: :
: : exec(GetEnv('COMSPEC'), '/C c:\windows\notepad.exe');
: : 

: :
: :///////////////////////////////////////////////////////////////////
: Try is one:
: : program test;
: : uses dos;
: : begin
:
: : command := '/c' + 'windows\notepad.exe' ;
: : swapvectors;
: : exec(getenv('COMSPEC'), command);
: : swapvectors;
: :////////////////////////////////////////////////////////////////////
:
: May you can help me in closing that program (written in perl)
: Best Regards
: Werner


Was that a suggestion for bpajk to try, or are you asking for help with that code?
Report
Re: exec() Posted by bpajk on 22 Oct 2003 at 6:27 AM
: : : : This message was edited by bpajk at 2003-10-21 12:12:5

: : : : My program doesn't go pass the exec() statement! How do I tell him to execute and go foward? When I used Dev-Pascal for a compiler it went passed but in Free-pascal it stops at exec().
: : : :
: : : : program test;
: : : : uses dos;
: : : : begin
: : : :   swapvectors;
: : : :   exec('c:\windows\notepad.exe','');
: : : :   swapvectors;
: : : :   readln
: : : : end.
: : : : 

: :
: : :
: : : What flavour of FPC? If it's the GO32V2 one, you may need to use:
: : :
: : :
: : : exec(GetEnv('COMSPEC'), '/C c:\windows\notepad.exe');
: : : 

: : :
: : :///////////////////////////////////////////////////////////////////
: : Try is one:
: : : program test;
: : : uses dos;
: : : begin
: :
: : : command := '/c' + 'windows\notepad.exe' ;
: : : swapvectors;
: : : exec(getenv('COMSPEC'), command);
: : : swapvectors;
: : :////////////////////////////////////////////////////////////////////
: :
: : May you can help me in closing that program (written in perl)
: : Best Regards
: : Werner
:
:
: Was that a suggestion for bpajk to try, or are you asking for help with that code?
:
It worked! But There is a trick to this:
If you use: exec('c:\windows\notepad.exe',''); It will not pass the exec() statement until the program is finished, but if you use: exec(GetEnv('COMSPEC'), '/Cc:\windows\notepad.exe'); it will execute the program and go pass. Thanx!


Report
Re: exec() Posted by Dominik101 on 28 Jan 2010 at 10:15 PM
Hi Bpajk,

I have the same problem in FPC, when opening the notepad.
SwapVectors;
Exec(GetEnv('COMSPEC'),'/C '+ '>notepad.exe c:\active.txt');
SwapVectors;


Exec() opens the notepad but the program doesn't go forward until notepad is closed.

I tried your code:
exec(GetEnv('COMSPEC'), '/Cc:\windows\notepad.exe');

but the effect is just the same.
The programs opens notepad and stops.

Can you help and tell how you solved the problem?
Report
Re: exec() Posted by Atex on 31 Jan 2010 at 10:23 PM
// Compiler: FPC

uses windows;

begin
 winexec('notepad.exe',1);
 writeln('Test'); 
 readln;
end.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.