Exec Function

Purpose

Loads and runs a program.

Syntax

% = Exec(file$, CmdLine)( function)

Exec file$, CmdLine( command)

file$, CmdLine:sexp

Description

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.

Example

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

Remarks

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.

See Also

Shell, ShellExec, System, WinExec

{Created by Sjouke Hamstra; Last updated: 04/10/2014 by James Gaite}