exec (STRING* program, STRING* options)
Opens an external program, document, URL, or batch file.
exec_wait (STRING* program, STRING* options)
Opens an external program, document, URL, or batch file, and waits for its termination.
Parameters:
program - file name of the
exe, batch file, or document, or URL to be opened.
options - command line parameter string to be passed to the
program,
or NULL for no command line options.
Returns:
0 if the program was not found or could not be started, nonzero otherwise.
Speed:
Slow
Remarks:
- The program parameter can
specify a full path (from the root), a partial path (from the current work folder),
or just a filename. In the latter case the exec function first looks for the
file in the work folder, and then in the in the folders specified by the system's
PATH
environment variable.
- If the program string
does not have a filename extension, the exec function first tries
the .COM extension, then the .EXE extension, then the .BAT extension, and
finally the .CMD
extension.
- 7.82
If the program string contains a URL or the name of a document, the standard internet browser or the standard editor for that document is opened.
- 7.79
"%PROG_DIR%" at the beginning of the program string is replaced by the program files folder, and "%EXE_DIR%" is replaced by the folder containing the engine executable.
- '\' characters in
strings, like for file paths, have to be given in C-Notation as "\\",
as in "%PROG_DIR%\\internet explorer\\iexplore.exe".
- The instruction
does not wait for the program to terminate, but returns immediately.
- If the external
program opens a window, the engine should be switched to window mode
before. Fullscreen
mode would hide other windows.
- 7.79
The external program can be controlled with the sys_message function.
Examples:
exec("%EXE_DIR%\\acknex.exe","samples\\terrain.hmp"); // open terrain in another engine window
exec("notepad","test.txt"); // open notepad
exec("%PROG_DIR%\\internet explorer\\iexplore.exe","http://www.3dgamestudio.com"); // open an URL with Internet Explorer
exec("http://www.3dgamestudio.com",NULL); // open an URL with the standard browser
See also:
PATH,
sys_message, sys_active
► latest
version online