Jump to content
Excelsior Forums

Calling an External Executable?

Recommended Posts


Thank you guys for helping me in the past. I have yet not got my thing to work ? but I have a question:

How do I call an external executable from Modula 2?

In TopSpeed my code has

FROM Lib IMPORT Exec;  --> For the Import Statement



For calling the external executable ?hh_prog.exe? Is this correct?, because it seems that my external executables are not getting called.

Thanks again for your help.


Share this post

Link to post
Share on other sites


I wanted to add that as is defined as:


and from another module:

Strin = ARRAY [0..inlen] OF CHAR;

I looked into Lib.def inside TS and it shows me:


                Params  :ARRAY OF CHAR;

                Env    :ExecEnvPtr) :CARDINAL;

So is the problem with as or with the NIL for Env?

Thanks a lot.


Share this post

Link to post
Share on other sites

If the function Lib.Exec() succeeds, the return value is nonzero. Check the return value first.

Also, try to add ".exe" file extension to the program name like "hh_prog.exe".

Note, if the program name does not contain a directory path, Lib.Exec() searches for the executable file in the same sequence as Windows does:

- the directory from which the main application started;

- the current directory for the main application;

- the Windows system directory;

- the Windows directory;

- the directories that are listed in the PATH environment variable.

Share this post

Link to post
Share on other sites

Dear sleepyhead,

Thanks for your reply. I am sorry I could not get back to you earlier ? I am in the middle of my exams.

I think the addition of the *.exe was the problem. Another problem was one of the executables was being called with the wrong parameters ? I don?t know why this was wrong though.

This thing still does not work completely ? but I am working on it. Thank you for your help


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now