• Keine Ergebnisse gefunden

('~ EXECUTE Statement

Im Dokument BASIC Language Reference Guide (Seite 163-168)

('~ EXECUTE Statement

Syntax

(

6929-3

The EXECU1E statement allows a BASIC program to execute any valid

TCL command and use the results of the command in later processing.

EXECUTE expression { {, {II} } redir.clause { {, {II} } redir.clause} ... } expression contains string in the format of a TCL command just as it

would be entered at the terminal; it may be a verb, PROC,

or cataloged BASIC program, followed by any parameters and options.

II provided for compatibility with earlier revisions of the Ultimate operating system; double slashes (II) cause a compilation error if they precede any parameter that does not end in a period (for example, IN.). In general, Ultimate advises using only a space or a comma as a separator between clauses.

redir.clause specifies source or destination for data in executed statement; may be any of the following:

CAPTURING var output to terminal from executed statement is redirected to var; if the statement being execu ted produces more than one line of data, each line in var is delimited by attribute marks; the last line of data is always terminated by an attribute mark;

equivalent to OUT. > or OUT.

=

clause

IN. < expr

IN.

=

expr

Ultimate BASIC

data in expr is stacked as input for the executed statement; if the statement to be executed accepts more than one line of data, each line of data in expr must be delimited by attribute marks; equivalent to

STACKING clause

3-85

Confidential and Proprietary to The Ultimate Corp.

Statements and Functions

output to terminal from executed statement is redirected to var; if the statement being executed produces more than one line of data, each line in var is delimited by attribute marks; the last line of data is always terminated by an attribute mark;

equivalent to CAPTURING clause

expr contains select list to be redirected to statement being executed; the elements of the list, typically item.ids, must be delimited by attribute marks;

there is an attribute mark after the last element;

equivalent to SELECT. < clause

returns all ERRMSG message numbers and parameters generated by executed statement;

ERRMSG numbers are separated by attribute marks;

parameters within a message are separated by value marks

select list generated by executed command is redirected to var; elements in the list, typically item.ids, are delimited by attribute marks; there is an attribute mark after the last element; equivalent to SELECT. > clause

expr contains select list is to be redirected to statement being executed; the elements of the list, typically item.ids, must be delimited by attribute marks; there is an attribute mark after the last element; equivalent to PASSLIST clause select list generated by executed command is redirected to var; elements in the list, typic all y item.ids, are delimited by attribute marks; there is an attribute mark after the last element; equivalent to RTNLIST

data in expr is stacked as input for the executed statement; if the statement to be executed accepts more than one line of data, each line of data in expr

6929-3 Confidential and Proprietary to The Ultimate Corp.

C

Description

(

Select Lists

6929-3

EXECUTE Statement

must be delimited by attribute marks; equivalent to IN. < or IN. =

Data stacked by the STACKING and IN. parameters can be used by other BASIC programs and by TCL-II verbs such as COpy and ED. Data cannot be stacked for use in PROC statements.

After the statement is executed, program control returns to the statement following the EXECUTE statement. If the EXECUTE statement changed the operating environment of the system in any way, the environment is not restored. Commands that may change the operating environment include the following:

• BREAK-KEY -OFF/BREAK-KEY-ON

• OFF (the system logs off and command is not returned to the BASIC program)

• spooler verbs such as SP-ASSIGN

• tape verbs such as T-ATT

• TABS

• terminal verbs, such as TERM

The following commands have no effect when EXECUTEd:

• CHARGE-TO

• LOGTO

The GET(MSG.) form of the GET statement may be used to obtain, one at a time, the messages generated by the statement that was executed.

When formatting the EXECUTE statement in your BASIC program, you may begin a new line after any comma.

A select list produced by an EXECUTE statement cannot be automatic all y carried over to the next EXECUTE statement. It can be redirected or used in a READNEXT statement in the same program. Thus, the following lists all items in MD:

EXECUTE "SELECT MD 'ED'"

EXECUTE "LIST MO"

Ultimate BASIC

Confidential and Proprietary to The Ultimate Corp.

3-87

Statements and Functions

3-88

A select list can be used as follows to list the selected items:

EXECUTE "SELECT MD 'ED''', RTNLIST X EXECUTE "LIST MD", PASSLIST X

A select list can be used as follows to read the next item:

EXECUTE "SELECT MD 'ED'"

10 READNEXT ID ELSE STOP PRINT ID

GOTO 10

When the select list is stored in a variable, the variable may be used in the FROM parameter in a READNEXT statement.

EXECUTE "SELECT MD 'ED'" RTNLIST X 10 READNEXT ID FROM X ELSE STOP

PRINT ID GOTO 10

The select list may be used as a dynamic array in that elements may be retrieved directly from X without affecting its function as a list. For example, A = x<17> will put the 17th item.id into A and X can still be used in a READNEXT statement. However, the list is not a dynamic array. If an element is changed in the list, the list is then converted to a dynamic array and can no longer be used as a select list. In that case, to use READNEXT with the data, the program can SELECT the dynamic array to a list.

Note : Unlike a dynamic array, a select list can contain more than 32,767 items; however, you cannot extract past the 32, 767th element in the list.

If a program uses DCOUNT to count the number of item.ids in the select list, the number returned is one higher than the actual number of elements in the list.

The RETURNING and CAPTURING clauses have no effect when a SELECT

verb is executed.

Ultimate BASIC 6929-3

Confidential and Proprietary to The Ultimate Corp.

(

C· ..

--~/

6929-3

EXECUTE Statement

N ole: The $COMPATIBILITY compiler directive affects the way EXECUTEfunctions with select lists and data stacks; for information, see the $COMPATIBILITY directive.

EXECUTE "WHO" The command WHO is executed; the output is displayed on user's screen; program control continues in sequence.

EXECUTE "WHO", OUT. > X The command WHO is executed; the

IF X<l> # "0 SYSPROG" THEN output is redirected to variable X.

PRINT "MUST BE ON LINE 0" X is tested for access to program,

STOP resulting in either a message and

END halt or program execution.

EXECUTE "COPY BP PROG1" , STACKING "COPY. PROG1" , RETURNING MSGS

EXECUTE "ED BP X", IN. < "L22":@FM:"EX", OUT. > X

The command COpy is executed, using the string "COPY.PROG I" as stacked input for COPY. The

ERRMSG number and any parameters produced for it are returned in MSGS.

The EXECUTE statement allows multiple redirection variables. Two lines of data, "L22" and "EX" are redirected to the command ED. The output is redirectea to variable X.

EXECUTE 'SELECT EMPFILE WITH SAL >= "10000"' RTNLIST X EXECUTE 'LIST EMP.ADDR.FILE' PASSLIST X

Ultimate BASIC

In the first EXECUTE statement, the select list is redirected to variable x, with the item.ids separated by attribute marks. The select list is then redirected to the LIST command in the second EXECUTE statement.

3-89

Confidential and Proprietary to The Ultimate Corp.

Statements and Functions

Im Dokument BASIC Language Reference Guide (Seite 163-168)