EXECUTE Statement

Executes a TCL command from DataBasic. Data (including lists) can be passed between the command and the program.

EXECUTE functions in the same way as the PERFORM statement, except as described in Operation.

This function is provided for compatibility with other MultiValue systems.

Syntax

EXECUTE command
{[ STACKING || ,//IN. < ] input-expr }
{[
PASSLIST {inputListVar} || ,//SELECT. < {inputListVar}] }
{[ RTNLIST {outputListVar} || ,//SELECT. > {outputListVar}] }
{[
CAPTURING || ,//OUT. > ] capture-var }
{[ SETTING || RETURNING ] setting-var }

The optional clauses can be used in any order.

Syntax Elements

command The TCL command to be executed, expressed as a variable or a literal enclosed in single or double quotes. Any terminal input required can be provided by preceding DATA statements or a STACKING or //IN clause.

STACKING input-expr

,//IN. < input-expr

Redirect data to the terminal input of the command being executed, where input-expr is a DataBasic expression that evaluates to the required terminal input. If required, input-expr can contain multiple lines, separated by attribute marks.

Terminal input can also be provided by preceding DATA statements (see PERFORM). If there are no DATA statements and no STACKING or ,//IN. clause is specified, any terminal input required by the command is requested from the command line.

PASSLIST {inputListVar}

,//SELECT. < inputListVar

Redirects a list (in the form of a dynamic array) from the variable inputListVar to the command specified in command. See PERFORM for details.

CAPTURING capture-var

,//OUT. > capture-var

Redirects output from the executed command to the variable specified by capture-var (see PERFORM for details).

RTNLIST {outputListVar}

,//SELECT. > outputListVar

Redirects a list generated by the command specified in command to the variable outputListVar as a dynamic array. See PERFORM for details.

SETTING setting-var

RETURNING setting-var

specifies that error message numbers and their parameters are assigned to the variable setting-var. See PERFORM for details.

Operation

EXECUTE functions in the same way as the PERFORM statement, except for the following:

Examples

EXECUTE "WHO"

The command WHO is executed; the output is not redirected to a variable, so it is displayed on the user's screen.

EXECUTE "WHO"", //OUT. > X

IF X<1>[1,8] # "0 SYSMAN" THEN

  PRINT "PROGRAM CAN ONLY BE RUN BY SYSMAN"

  STOP

END

The command WHO is executed, with the output redirected to variable X. If X does not have a particular value, a message is displayed and the program terminates.

EXECUTE "COPY BP PROG1", //IN. < "BACKUPPROG1"

The command COPY is executed using the redirected string "BACKUPPROG1" instead of the user's terminal input.

EXECUTE "RUN BP TWOINPUT", //IN. < "ONE":CHAR(254):"TWO"

Assuming that the DataBasic program TWOINPUT has two INPUT statements: The first receives the data "ONE"; the second, the data "TWO".

EXECUTE "ED BP X", //IN. < "L22":CHAR(254):"EX", //OUT. > X

Two lines of data, "L22" and "EX", are redirected to the command ED. The output is redirected to variable X.

EXECUTE 'SELECT EMPFILE WITH SAL >= "10000"',//SELECT. > X
EXECUTE 'LIST EMP.ADDR.FILE', //SELECT. < X

In the first EXECUTE statement the select list resulting from the SELECT statement is redirected to variable X. This list then used as input to the LIST command in the second EXECUTE statement.

Go to top button