Run

Description

Runs the specified application program.

Syntax

Run ( string {, windowstate } )

Argument

Description

string

A string whose value is the file name of the program you want to execute. Optionally, string can contain one or more parameters for the program.

windowstate (optional)

A value of the WindowState enumerated datatype indicating the state in which you want to run the program:

  • Maximized! — Maximized; enlarge the program window to its maximum size when it starts

  • Minimized! — Minimized; shrink the program window to an icon when it starts

  • Normal! — (Default) Run the program window in its normal size

Returns

Integer. Returns 1 if it is successful and -1 if an error occurs. If any argument’s value is null, Run returns null.

Usage

You can use Run for any program that you can run from the operating system. If you do not specify parameters, Run opens the application and displays the first application window. If you specify windowstate, the application window is displayed in the specified state.

If you specify parameters, the application determines the meaning of those parameters. A typical use is to identify a data file to be opened when the program is executed. If you are running another PocketBuilder application, that application can call the CommandParm function to retrieve the parameters and process them as it sees fit.

If the file extension is omitted from the file name, PocketBuilder assumes the extension is .EXE. To run a program with another extension (for example, .BAT, .COM, or .PIF), you must specify the extension.

Examples

Example 1

This statement runs the Microsoft Windows Clock accessory application in its normal size:

Run("Clock")

Example 2

This statement runs the Microsoft Windows Clock accessory application minimized:

Run("Clock", Minimized!)

Example 3

This statement runs the program WINNER.COM on the C drive in a maximized state. The parameter passed to WINNER.COM opens the file EMPLOYEE.INF:

Run("C:\WINNER.COM EMPLOYEE.INF", Maximized!)

Example 4

This example runs the DOS batch file MYBATCH.BAT and passes the parameter TEST to the batch file. In the batch file, you include percent substitution characters in the commands to indicate where the parameter is used:

Run("MYBATCH.BAT TEST")

Example 5

In the batch file the following statement renames FILE1 to TEST:

RENAME c:\PB\FILE1 %1