RunProgram

Description:

baRunProgram runs an external application and can optionally wait until the other program quits before continuing.

Platforms:

Windows and Macintosh

Usage:

Result = baRunProgram( Program , State, Wait )

Arguments:

String, string, integer.
Program is the name of the program to run.
On Windows, can be one of these:
    "Normal"shows in its usual state.
    "Hidden"is not visible.
    "Maximised"shows as a maximised window.
    "Minimised"shows as an minimised icon.
On Macintosh, State is ignored.
Wait determines whether the Authorware program continues, or if it waits for the external program to finish before continuing. Can be either true or false.

Returns:

Integer.
Returns a meaningless number greater than 31.
If the return is less than 32, then an error occurred. Some possible Windows error numbers are:

System was out of memory, executable file was corrupt, or relocations were invalid.

Unspecified error.

File was not found.

Path was not found.

Attempt was made to dynamically link to a task, or there was a sharing or network-protection error.

Library required separate data segments for each task.

There was insufficient memory to start the application.

10 

Windows version was incorrect.

11 

Executable file was invalid. Either it was not a Windows application or there was an error in the .EXE image.

12 

Application was designed for a different operating system.

13 

Application was designed for MS-DOS 4.0.

14 

Type of executable file was unknown.

15 

Attempt was made to load a real-mode application (developed for an earlier version of Windows).

16 

Attempt was made to load a second instance of an executable file containing multiple data segments that were not marked read-only.

19 

Attempt was made to load a compressed executable file. The file must be decompressed before it can be loaded.

20 

Dynamic-link library (DLL) file was invalid. One of the DLLs required to run this application was corrupt.

21 

Application requires 32-bit extensions.

On Macintosh, an error always returns 0.

Examples:

Director:
OK = baRunProgram( "Notepad.exe", "maximised", false )

Authorware:
OK := baRunProgram( "Notepad.exe", "maximised", false )
 

Notes:

On Windows, where possible, the complete path to the program should be specified. If a path is not provided, then Windows searches for the file in the following order: the current directory, the Windows directory, the Windows system directory, the directory containing the executable file for the current task, the directories listed in the PATH environment variable, the directories mapped in a network.

You are not limited to supplying just an executable file name; you can add any other command line parameters that the executable supports. For example, to load the Adobe Acrobat Reader with mydoc.pdf, use the following call:

baRunProgram( "acroread.exe mydoc.pdf", "maximised", false )

To print an Acrobat file, you can use

baRunProgram( "c:\acrobat\acroread.exe /p mydoc.pdf", "Hidden", true )

On Macintosh, you must supply the full path to the file. Command line arguments are not supported.

If used with the Wait option, this function will not return control to Authorware/Director until the jumped to program has quit. If your user switches back to the Authorware program, it will appear to have frozen. You may choose to display an on-screen message to inform your user of this. You can also use the baWaitTillActive function to pause execution until the Authorware/Director window becomes active again.
 

See also:

baWaitTillActive
baWaitForWindow
baNextActiveWindow
baOpenFile
baShell