Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

exec()

bpajkbpajk Posts: 156Member
[b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
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().
[CODE]
program test;
uses dos;
begin
swapvectors;
exec('c:windows
otepad.exe','');
swapvectors;
readln
end.
[/CODE]


Comments

  • ManningManning Posts: 1,621Member
    : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : 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().
    : [CODE]
    : program test;
    : uses dos;
    : begin
    : swapvectors;
    : exec('c:windows
    otepad.exe','');
    : swapvectors;
    : readln
    : end.
    : [/CODE]

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

    [code]
    exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    [/code]
  • werner02werner02 Posts: 5Member
    : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : 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().
    : : [CODE]
    : : program test;
    : : uses dos;
    : : begin
    : : swapvectors;
    : : exec('c:windows
    otepad.exe','');
    : : swapvectors;
    : : readln
    : : end.
    : : [/CODE]

    :
    : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    :
    : [code]
    : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : [/code]
    :
    :///////////////////////////////////////////////////////////////////
    Try is one:
    : program test;
    : uses dos;
    : begin

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

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


  • ManningManning Posts: 1,621Member
    : : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : : 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().
    : : : [CODE]
    : : : program test;
    : : : uses dos;
    : : : begin
    : : : swapvectors;
    : : : exec('c:windows
    otepad.exe','');
    : : : swapvectors;
    : : : readln
    : : : end.
    : : : [/CODE]
    :
    : :
    : : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    : :
    : : [code]
    : : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : : [/code]
    : :
    : :///////////////////////////////////////////////////////////////////
    : Try is one:
    : : program test;
    : : uses dos;
    : : begin
    :
    : : command := '/c' + 'windows
    otepad.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?
  • bpajkbpajk Posts: 156Member
    : : : : [b][red]This message was edited by bpajk at 2003-10-21 12:12:5[/red][/b][hr]
    : : : : 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().
    : : : : [CODE]
    : : : : program test;
    : : : : uses dos;
    : : : : begin
    : : : : swapvectors;
    : : : : exec('c:windows
    otepad.exe','');
    : : : : swapvectors;
    : : : : readln
    : : : : end.
    : : : : [/CODE]
    : :
    : : :
    : : : What flavour of FPC? If it's the GO32V2 one, you may need to use:
    : : :
    : : : [code]
    : : : exec(GetEnv('COMSPEC'), '/C c:windows
    otepad.exe');
    : : : [/code]
    : : :
    : : :///////////////////////////////////////////////////////////////////
    : : Try is one:
    : : : program test;
    : : : uses dos;
    : : : begin
    : :
    : : : command := '/c' + 'windows
    otepad.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
    otepad.exe',''); It will not pass the exec() statement until the program is finished, but if you use: exec(GetEnv('COMSPEC'), '/Cc:windows
    otepad.exe'); it will execute the program and go pass. Thanx!


  • Dominik101Dominik101 Posts: 1Member
    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
    otepad.exe');

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

    Can you help and tell how you solved the problem?
  • AtexAtex Posts: 268Member
    [code][color=Blue]// Compiler: FPC

    uses windows;

    begin
    [b]winexec('notepad.exe',1);[/b]
    writeln('Test');
    readln;
    end.[/color][/code]
Sign In or Register to comment.