CHAIN


ANSI

 

The CHAIN instruction loads a PL/B program and passes control to it. The instruction uses the following format:

 

 

[label]

CHAIN

{program}

 

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:

  1. {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.

  2. 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.

  3. A Datapoint style filename of `filename/ext:drv' is converted to a Sunbelt format as follows:

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. Control is passed to the first executable instruction in the program being loaded and executed.

  10. Any TRAP that has been set is cleared.

  11. If a FILEPI instruction is active, it is terminated.

  12. All Flags (Condition, Pseudo Condition and Function) are cleared (set to FALSE).

  13. The subroutine call stack is cleared.

  14. The following special KEYIN and DISPLAY conditions are turned off when chaining another program. Any others that had been turned on remain in effect.

  15.  

    Inverse video

    Dual intensity

    Graphics mode

    Invert text

    Upper case only

    Decimal point implied

    Blink on

    Underline on

  1. 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.

  2. Unlike other global data, graphical objects are destroyed during a CHAIN operation except the FONT and COLOR objects.

  3. 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

 



PL/B Language Reference CALL and CALLS CLEAREVENT