Please enable JavaScript to view this site.

ESL Documentation

Action Statement

Transfer control to another ESL program.

change to program PROGRAM_NAME

PROGRAM_NAME

A string value representing the name of the ESL program to which you want to transfer control.

Description

When ESL executes a change to program statement, it causes the current program to terminate. The display is cleared, and all objects, variables, constants, classes, patterns, and responses belonging to the program that is being exited cease to exist. Note, however, that global variables still exist, started applications continue to run, and open selection devices remain open. The new program begins execution with its response to start statement.

In most cases, the change to program statement should be the last action statement in the response definition in which it is specified, since any following statements will not be executed unless an error condition exists.

If ESL cannot find the program specified in PROGRAM_NAME, it will execute any action statements that follow the change to program statement. This can be useful for error detection purposes.

The value for PROGRAM_NAME must be a string value that contains the name of the program (with or without the .WEB extension). It does not have to be in the same directory as the program that is being terminated; for example, you can specify a full directory pathname for it. When specifying a path, include an extra backslash each time one is specified, since one backslash is the escape character in strings.

Global Variables in change to program Statements

Ordinarily, initialization of global variables is specified only in the first program. If any subsequent program initializes the global variable (for example, "global variable X is 100"), the initialization is ignored, except in the case of a new global variable. Therefore, do not initialize global variables in any program that will be run with the change to program statement. Even when control is transferred to a program that was created with the save program as statement, the change to program statement transfers the value of its current global variables to the new program.

When a change to program statement is executed, new global array dimensions are not checked against the old dimensions. Therefore, if the number of elements for any dimension or the number of dimensions of the array in the new program is different from what was defined in the original program, the results are unpredictable.

Example

 

response to Database_Key

 send ExitCode to CurrentApp

 change to program "Database"

 

response to GoBack_Key

 change to program "c:\\code\\first"

See Also

exit Action Statement