CHAIN
ANSI
The CHAIN instruction loads a PL/B program and passes control to it. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
program
Required. A previously defined Character String Variable or string Literal containing the name of the program that is executed.
Flags Affected: EOS, LESS, OVER, ZERO, Function Key
Note the following:
{program} must be provided and must contain the name of the program that is executed. If a string variable is used, only the Logical String contents are used.
If a drive or path is not specified as part of the program name, the current directory is searched first. If unsuccessful, the directories that have been established in the PLB_PATH environment variable or SEARCHPATH instruction are searched.
A Datapoint style filename of `filename/ext:drv' is converted to a Sunbelt format as follows:
If an extension is found, the '/' extension delimiter is now changed to a Sunbelt extension delimiter character defined in the screen definition file used by the runtimes. The default extension delimiter would replace the '/' delimiter with a period.
The ':drv' specification in a Datapoint filename
is changed to a substituted string defined by a UET keyword that must be defined by appending the Datapoint
drive identification string to 'PLBVOL_'. In the above case the UET string must be defined as 'PLBVOL_DRV={path}'
in the environment table or in the 'PLBWIN.INI' file. If the UET keyword is not found, the runtime attempts
to open the file with no changes. However, if the UET keyword is found, the runtime changes the filename
to '{path}\filename.ext'.
Example: UET has environment entry defined as PLBVOL_WORK=C:\PLC
CHAIN "PROG/PLC:WORK"
Actual file CHAINed as: C:\PLC\PROG.PLC
A CFAIL error occurs if the program file is not found, is incompatible with the initiating program, has common data area misalignment or has global data area incompatibility. An error will also occur if there are insufficient system resources available to load the program.
This PL/B implementation supports the ANSWER/MASTER concept of program chaining. Typically, the ANSWER program provides the initial system security (password verification). The MASTER program is the main menu for selecting which functions are performed and initiating the CHAINs to the appropriate program. In this concept, any chained program that terminates due to an untrapped error or via a STOP instruction returns control to its MASTER program. This includes a MASTER program initiated through chaining by an ANSWER program. A chained program that terminates via a DSCNCT returns control to its ANSWER program. This concept allows a system design that keeps the operator from having to interface with the operating system.
PLBCMP allows for specific ANSWER and MASTER program designation within each screen definition file. SUNDB86A and SUNDB86M assume the default names of ANSWER and MASTER.
The first PL/B program initiated from an operating system command line becomes both the ANSWER and MASTER for any subsequent programs. However, in this case a STOP within the initial ANSWER/MASTER program returns control to the operating system.
Any data beyond the actual program name is stored in the system variable S$CMDLIN and is available to the chained program for manipulation. If no data is beyond the actual program name, the system variable S$CMDLIN is not changed.
Control is passed to the first executable instruction in the program being loaded and executed.
Any TRAP that has been set is cleared.
If a FILEPI instruction is active, it is terminated.
All Flags (Condition, Pseudo Condition and Function) are cleared (set to FALSE).
The subroutine call stack is cleared.
The following special KEYIN and DISPLAY conditions are turned off when chaining another program. Any others that had been turned on remain in effect.
|
Inverse video |
Dual intensity |
|
Graphics mode |
Invert text |
|
Upper case only |
Decimal point implied |
|
Blink on |
Underline on |
All data defined as common or global is passed "as is" to the new program. Any files in common or global are left open but the file position must be reestablished.
Unlike other global data, graphical objects are destroyed during a CHAIN operation except the FONT and COLOR objects.
Any separately compiled modules that have been loaded explicitly or implicitly are unloaded when a program chains to another program with the CHAIN, STOP, or DSCNCT instructions. Any global data items that have been defined remain defined in the global data area.
See Also: Example Code, BATCH, EXECUTE, ROLLOUT, SHUTDOWN, Program Control Instructions
![]() |