Loads and runs a program.
% = Exec(file$, CmdLine)( function)
Exec file$, CmdLine( command)
file$, CmdLine:sexp
The Exec(file$, CmdLine) function invokes program file$ and gives it the command line CmdLine.
The file$ expression contains the name of the called program. The program name includes the full pathname.
The CmdLine expression contains the command line which is inserted in the program segment prefix of the called program.
Global a%
If Exist(WinDir + "\notepad.exe")
a% = Exec(WinDir + "\notepad.exe", "")
Message "return value: " & Format(a%)
Else
Message "Program not found"
EndIf
Do
Sleep
Until Me Is Nothing
Exec internally uses the function WinExec(). If you want to determine, if the called program is still active or not, you must use System instead, which returns the handle of the process and allows controlling it. Also, System allows, by using the parameter Wait, to wait until the program has finished.
Shell, ShellExec, System, WinExec
{Created by Sjouke Hamstra; Last updated: 04/10/2014 by James Gaite}