CHAIN

CHAIN

Top  Previous  Next

 

The CHAIN statement terminates the current program and executes a command.

 

 

Format

 

CHAIN expr

 

where

 

exprevaluates to a command.

 

The current program terminates immediately, discarding local variables but retaining named common variables. The command defined by expr is executed as though it replaced the sentence which invoked the program in which the CHAIN statement occurs. If this sentence is in a paragraph, the remainder of the paragraph will be executed when the CHAIN'ed program terminates.

 

The exact behaviour of CHAIN when executed from a program started by a PROC depends on the VOC record type of the target item referenced by expr. If this is a further PROC, any stacked PROCs leading up to the program that performed the CHAIN are discarded. If the target is not a PROC, control will return to the PROC that executed the program performing the CHAIN when the chained command terminates.

 

The unnamed common block is discarded on execution of a CHAIN unless the CHAIN.KEEP.COMMON mode of the OPTION command is active.

 

CHAIN is provided primarily for compatibility with other systems. The same effect can usually be better achieved using EXECUTE.

 

 

Examples

 

CHAIN "RUN PROGRAM2"

 

This program fragment terminates the current program and executes PROGRAM2 in its place.