TCLREAD Statement

Returns the command line used to execute the current program.

This function is available in all compatibility modes (set with the $OPTIONS statement).

Syntax

TCLREAD{(element)} varCommandLine

Syntax Elements

element An integer that specifies a syntax element in the command. 0 specifies the command name.

If element is omitted, TCLREAD returns the complete command line (except for options).

It is recommended that you always specify an element (see examples below).

Note that the element parameter must be enclosed in parentheses.

varCommandLine A variable in which to return the command line:

  • If an element is specified, single or double quotes enclosing the element are removed.

    If there is no syntax element in the specified position, TCLREAD returns a null string.

  • If element is omitted, any parameters enclosed in single or double quotes are returned unchanged (quotes are not removed).

  • Options preceded by an open parenthesis are not returned. To obtain this information, use SYSTEM(15).

Example 1

Item Test1 in BP file contains:

A = 40
B = 30
C = A+B
TCLREAD CMD
PRINT "The result of ":CMD:"is ":C
TCLREAD(0) VERB
PRINT "The command was ":VERB
TCLREAD(1) PARAM
PRINT "The first parameter was ":PARAM
TCLREAD(2) PARAM
PRINT "The second parameter was ":PARAM
TCLREAD(3) PARAM
PRINT "The third parameter was ":PARAM

When run as follows:

RUN BP TEST1

this program prints:

The result of RUN BP TEST1 is 70
The command was RUN
The first parameter was BP
The second parameter was TEST1
The third parameter was

Example 2

Item Test2 in file BP contains:

PARAM = ""
I = 0
LOOP
   TCLREAD(I) PARAM
   UNTIL PARAM = "" DO
      PRINT "TCLREAD(":I:") = ":PARAM
      I += 1
REPEAT

Then entering:

RUN BP TEST2 "myparam"

displays:

TCLREAD(0) = RUN
TCLREAD(1) = BP
TCLREAD(2) = TEST2
TCLREAD(3) = myparam

See Also

SENTENCE function. This has the same functionality as the TCLREAD statement, but returns a string containing the command line instead of assigning it to a variable.

SYSTEM(15). This returns the options specified as part of the last TCL statement.