Skip to main content

CHAIN

Executes a MultiValue command from a program, exiting the program.

Synopsis

CHAIN command

Arguments

command A MultiValue command specified as a quoted string.

Description

The CHAIN command executes the specified Caché MultiValue command, but does not return execution to the MVBasic program. Commonly, CHAIN is used with the MultiValue RUN command to “chain” execution from one program to another. It initially searches the VOC for the command; if the command is not found in the VOC, it searches the global catalog. For lookup details, refer to CATALOG in the Caché MultiValue Commands Reference.

CHAIN does not create a new execution environment. Therefore any select lists that were active when CHAIN was invoked are retained as the active select lists of the invoked command.

CHAIN cannot pass values to command. Because CHAIN does not return to the invoking program, it cannot pass a return value from command.

EXECUTE, PERFORM, and CHAIN

The EXECUTE command executes one or more MultiValue commands from within MVBasic, then returns execution to the next MVBasic statement in the invoking program. EXECUTE creates a new execution environment; select lists that were active when EXECUTE was invoked are not retained by its invoked MultiValue commands. EXECUTE can explicitly pass values to the MultiValue command(s) and return values from the MultiValue command(s).

The PERFORM command executes one or more MultiValue commands from within MVBasic, then returns execution to the next MVBasic statement in the invoking program. PERFORM cannot pass or return values.

The CHAIN command executes a single MultiValue command from within MVBasic. It does not return execution to the invoking program. CHAIN cannot pass values.

Examples

The following example issues the MultiValue RUN command, to initiate execution of the bignumprog MVBasic program:

IF x>100 
  THEN
    CHAIN "RUN bignumprog"
    END
 ELSE
    PRINT "continuing execution"
    END

Emulation

In jBASE emulation, CHAIN does not pass the default select list (select list 0) to the invoked program.

In UniData and UDPICK emulations, a command name with an initial character of * is handled as a global name. CHAIN removes the leading * and then looks up the resulting command name in the global catalog in SYS.MV, rather than looking up in the VOC. If the runtime environment is not a UniData emulation, a normal VOC lookup is done on the *command name.

See Also

FeedbackOpens in a new tab