A constant in TCL must be an integer, a real, or a string. It may be single-valued or multi-valued. If multi-valued, the values must appear in parentheses, separated by commas or spaces.
The "null value" constant consists of two adjacent "-" characters. The null value is a value with an element count of zero. Example:
For the above statement to be valid, the variable "I" must be declared to be "nullable," i.e., allowing a zero count.
The rules for acceptable integer and real constants are described in the "TAE Command Language (TCL) User's Manual."
A string constant consists of any characters acceptable in the host system's character set.
The rules for quoting string constants are as follows:
MAIL Harry Jane F=file1 !see rule 2 LET X = "file1" !see rule 1 IMGCOPY filel libe/file2 !see rule 3 PUTMSG "Send this to Harry" !see rule 2
In TCL, two consecutive quotation marks indicates an empty string, that is, a string with zero length.
If a parameter value in a proc invocation is omitted, the default value is assumed; if an element in a value list is omitted, the value assumed is zero for a numeric, or the empty string for a STRING type variables.
The value field (i.e., the right hand side) of a FOR or LET command may not be omitted.
Examples:
LET X ="" !Set X to empty string LET X = !Error PROC x=1, y=(1,,100) !Use zero for y(2) PROC X=, Y=2 !Use default for X
A TCL variable is an object that may be assigned a value using the LET command (e.g., LET x = 2). Variables may be used interactively as well as in procedures.
The following attributes are associated with variables:
Local variables are declared using the LOCAL command; global variables are declared using the PARM command in a GLOBALS PDF. Parameters and parameter qualifiers are declared using the PARM command.
In general, a variable is referenced by specifying the name of the variable or the name of a variable followed by a subscript.
A parameter qualifier is a variable associated with another variable. Parameter qualifiers are referenced by specifying the parameter name, followed with a ".", followed by the qualifier name with no spaces in between. All rules which apply to variables will also apply to the parameter qualifiers, except as specified.
The nth element of variable X is referenced by "X(n)". This syntax is valid anywhere a variable reference is permitted, except:
A subscript may be any valid TCL integer expression.
If variable X is a parameter qualifier to variable V, the nth element of variable X is referenced by "V.X(n)".
The variable types in TCL are INTEGER, REAL, STRING, KEYWORD, NAME, and FILE. Types are associated with a variable explicitly, through a LOCAL or PARM command.
The rules for acceptable values for each type are:
A multi-valued variable is a variable that is declared to have a maximum count greater than one. References to multi-valued variables are acceptable in the following places:
An unsubscripted multi-valued variable is not permitted in an arithmetic or string expression.
A variable may be declared to have a variable number of elements (using the COUNT attribute). If a variable is declared to have a variable number of elements, then the actual count is set to the count implied by the last assignment. The actual count is available through the $COUNT built-in function.
LOCAL x COUNT=1:4 INITIAL=1 !Actual count=1 . . . LET x = (1,4,32) !Actual count=3 LET x = 2 !Actual count=1
When referencing individual elements of a multi-valued variable, the index value must not be greater than the actual count.
A nullable variable is allowed to assume the null value. The null value is indicated by "--" and may be regarded as a vector with a count of zero and (consequently) no components.
Arithmetic may not be performed with null values. (Arithmetic is only valid for variables with a count of one.)
A parameter declared to be nullable has the nice property that a "special value" exists (i.e., the null value) without usurping the space of substantial values. Applications often use the null state of a nullable parameter as a flag to indicate "do nothing".
An example of using the null value as a special flag is the hypothetical IMGCOPY proc:
PROCESS PARM INPUT TYPE=FILE PARM OUTPUT TYPE=FILE PARM RECORDS TYPE=INTEGER COUNT=O:1 + DEFAULT=-- !null by default END-PROC
This proc, by default, copies the entire INPUT file to the OUTPUT file. If, however, the user sets RECORDS to a substantial value, the specified number of records is copied.
Note that "null value" is different from "no value." When a proc invocation request is processed by TAE, the request is rejected if one of the parameters has no value. If a parameter has no DEFAULT specification, a value must be supplied in the invocation request. A nullable parameter, like any other parameter, must have a value upon proc invocation; the value for a nullable parameter may be a substantial value or the null value.
A variable's scope may be local or global.
A local variable is declared using the LOCAL command. A local variable may be referenced only within the PDF in which it is declared.
Local variables may be qualified, using the same syntax and rules as for qualification of parameters. (See Section 2.3.4.) In the following example, the local variable SAT is qualified by the parameters in the internal proc, SATQUALS:
procedure parmset name=SATQUALS parm satid ! Satellite ID parm type ! Satellite type end-proc local sat init=LANDSAT quals=SATQUALS body let sat.satid= "LST-D" let sat.type = "POLAR" someproc @sat|@sat.satid, @sat.type| end-proc
Note: The LET statement copies only the highest level value; it does not copy the qualifiers. For example, if A and B are variables with the same qualifier Q, "LET A = B"sets A to the value of B, but does not set Q.
Note that a local variable contained in a PAR file may be restored into a parameter that has the same name as the local. This is true for the TCL RESTORE command qualifier and also for TUTOR's RESTORE command.
A global variable may be accessed from any execution level. The rules for global variables are:
DEFPAR WINDOW (0 767 0 767)The value of WINDOW on the proc invocation line overrides the default value declared in the PDF.
An internal proc may access variables declared within itself or in an outer proc. The variable is first searched for in the internal proc, and if it is not found, the search moves to the outer proc. The search continues on through the layers of outer procs ending with the outermost, containing proc. However, the internal proc may only delete variables declared within itself.
An outer proc may not access the variables declared in its internal procs.
A parameter has the status of a local variable within the procedure where the parameter is declared. The following rules therefore apply:
If the type is NAME, the effect of assignment is to set the value in the referenced variable.
The count of an undefined TCL value is -1; thus, a procedure may use the $COUNT function to determine whether the reference of a NAME parameter has a value.
Implicit variables are local or global variables that have been declared within TCL.
By convention, the names of implicit global variables start with "$". The globals and the corresponding implicit definitions are as follows.
$AECHO: | TYPE=STRING COUNT=1:1O DEFAULT=NO VALID=(YES,NO,FULL,BODY,TRACE) $AECHO is the echo global for asynchronous jobs. The values for $AECHO are the same as $ECHO, except that level 0 is always echoed. $AECHO may be set using the LET command. |
$APLIB: | TYPE=STRING COUNT=0:15 DEFAULT="" $APLIB contains the names of the currently active application libraries. At the beginning of a session, SAPLIB consists of the null value, indicating that there are no application libraries defined for the hierarchy search. |
$BECHO: | TYPE=STRING COUNT=1:10 DEFAULT=NO VALID=(YES,NO,FULL,BODY,TRACE) $BECHO is the echo global for batch jobs. The values for $BECHO are the same as $ECHO, except that level 0 is always echoed. $BECHO may be set using the LET command. |
$DEFCMDO: | TYPE=STRING DEFAULT=-- COUNT=1:50 $DEFCMDO is a multi-valued string containing the string equivalents for commands defined by the DEFCMD command. Each value is of the form "command=translation" where "command" is the command the user enters and "translation" is the character string substituted for the command. An example of a value in $DEFCMDO would be MSGH*ELP=HELP-MESSAGE where "*" indicates that the left-hand characters may be used as an abbreviation. If more than 50 commands are defined, TAE creates another global named SDEFCMD1, continuing up to $DEFCMD9 if necessary. |
$DYNTUT: | TYPE=STRING VALID=(SCREEN,NOSCREEN) DEFAULT=NOSCREEN $DYNTUT controls the tutor screen formatting for dynamic tutor. If "NOSCREEN", then "NOSCREEN" tutor mode is used. If "SCREEN", then normal screen-oriented'' tutor mode is used. $DYNTUT may be set using the LET command. |
$ECHO: | TYPE=STRING COUNT=1:10 DEFAULT=NO VALID=(YES,NO,FULL,BODY,TRACE) $ECHO is the echo global for synchronous jobs. The ith element of SECHO applies to the ith level of proc with level 0 never echoed. In addition, the last element set for SECHO applies to all subsequent levels. If "BODY" or "YES", the body portion of the procedure will be displayed as the commands are executed; if "FULL", the declarations plus the body will be echoed; if "TRACE", the full file specification of the PDF will be echoed upon proc invocation; and if "NO", no echo at the level. $ECHO may be set using the LET command. |
$FILEVER: | TYPE=STRING COUNT=1:2 DEFAULT=NO VALID=(YES,NO) $FILEVER defines whether or not TAE checks for the existence of a file when a parameter is of type FILE and ACCESS is IN or INOUT. If $FILEVER is "YES" then file existence is checked; file existence is not checked if $FILEVER is "NO". The default for $FILEVER is "NO". |
$JOB: | TYPE=STRING $JOB is automatically initialized to the name of the current job. For interactive jobs, SJOB is equal to $SESSION; for ASYNC jobs, $JOB is the name assigned by the parent job. |
$LASTCMD: | TYPE=STRING DEFAULT="" COUNT=0:20 $LASTCMD contains the 20 most recent interactive command strings typed by the user. $LASTCMD(1) is the most recent command, $LASTCMD(2) is the command previous to SLASTCMD(1), and so on. Thus, a user may examine old commands with "DISPLAY $LASTCMD". If SLASTCMD is set to the null value ("LET $LASTCMD = =--"), the archiving of previous commands into $LASTCMD is disabled, and the user may not recall commands using the arrow keys. |
$LOG: | TYPE=(STRING,file-spec-size) DEFAULT="session.tsl" In a future release of TAE, $LOG will contain the file specification of the current session log. $LOG is automatically initialized by TAE when the first ENABLE-LOG command is executed. |
$MENUOPT: | TYPE=STRING COUNT=0:4 VALID=(NO_PRESS_FOR_MENU, NO_TAG,NO_NAME,NO_LIBRARY) DEFAULT=-- $MENUOPT allows suppression of the "Press RETURN key for menu" message and controls the display of menu header information. If $MENUOPT has the value NO_PRESS_FOR_MENU, then the Terminal Monitor suppresses the "Press RETURN key for menu" message that usually appears before a menu is reprinted. If $MENUOPT has the null value (--), the default, then the "Press RETURN key for menu" message is displayed. "NO_TAG" suppresses the "Menu:" part of the menu screen header; "NO_NAME", the proc name; and "NO_LIBRARY", the library name. Note also that to set more than one of these attributes, include the attributes in a list. For example, LET $MENUOPT=("NO_PRESS_FOR_MENU", "NO_TAG"). The value of $MENUOPT, like all string global variables, may be changed from a program using the XQSTR and XQOUT subroutines (FORTRAN), the q_string and q_out subroutines (C), or the Vm_SetString and Vm_SetTCLVar subroutines (C). |
$MENUS: | TYPE=STRING COUNT=0:50 $MENUS is the stack of active menu definition file names. $MENUS(1) is the root menu, $MENUS(2) is the menu activated under the root, and so on. The current menu is $MENUS(n), where "n" is $COUNT($MENUS). An executing proc may alter $MENUS in order to set the menu that the user sees upon proc termination. |
$MESSAGE: | TYPE=STRING VALID=(ATTN,SILENT,PAUSE,BELL) DEFAULT=SILENT $MESSAGE controls the terminal action when a message is displayed. With "BELL", TAE sounds the terminal bell and continues; with "PAUSE", the user must press the RETURN key to continue execution; "ATTN" is the combination of "BELL" and "PAUSE"; and "SILENT" means there is no special action for messages. $MESSAGE may be set by the user with the LET command. |
$PARENT: | TYPE=STRING For ASYNC jobs, $PARENT is the name of the parent job, i.e., the job that initiated the ASYNC job. For interactive jobs, $PARENT is the null value. |
$PROMPT: | TYPE=(STRING,15) DEFAULT="TAE" The value of $PROMPT is used as the standard TCL prompt. |
$RUNTYPE: | TYPE=(STRING,12) DEFAULT="INTERACTIVE" $RUNTYPE contains "BATCH", "ASYNC" or "INTERACTIVE" and is automatically set by TAE. $RUNTYPE is implicitly referenced by every PDF. "INTERACTIVE" is the initial value for an interactive session. |
$SESSION: | TYPE=STRING $SESSION is a string which uniquely identifies the current batch, asynchronous or interactive session. $SESSION is implicitly referenced by every PDF. |
$SFI: | TYPE=INTEGER DEFAULT=1 The value of $SFI ("success/fail indicator") upon the termination of a proc determines the TCL error handling. A positive value indicates success and a negative value indicates failure. When a proc is invoked, $SFI is automatically set to 1 before the execution of a proc. (See Section 3.5.) $SFI is implicitly referenced by every PDF. |
$SKEY: | TYPE=(STRING,17) DEFAULT="" $SKEY is a proc termination status key and is used as a method of passing completion information to the invoking proc. When a proc is invoked, $SKEY is automatically set to the empty string before execution of the proc. $SKEY is implicitly referenced by every PDF. |
$SWITCH: | TYPE=INTEGER DEFAULT=0 $SWITCH is the TAE "switch word." The switch word is used by programmers to pass special mode flags to procs. The low-order eight bits of the switch word are reserved for use by the TAE developers. Two $SWITCH values are of special interest.
$SWITCH is implicitly referenced by every PDF. |
$SYSCHAR: | TYPE=STRING COUNT=0:6 $SYSCHAR contains information on system characteristics. The keyword strings in this variable are referenced by help files to generate "conditional" help text. Thus, one help file may be used on several different implementations of TAE and, where needed, generate system-specific information. |
$SYSLIB: | TYPE=(STRING, file-spec-size) COUNT=0:1 DEFAULT=SYSLIB $SYSLIB contains the name of the system library. At the beginning of a session, $SYSLIB is automatically set to the name of the installation's standard TAE system library. $SYSLIB may be altered during a session in order to change the proc hierarchy search. If $SYSLIB is set to the null string, the hierarchy search bypasses the system library. |
$TUTOR: | TYPE=STRING DEFAULT=SCREEN VALID=(SCREEN,NOSCREEN) $TUTOR controls the tutor screen formatting. If it is set to "NOSCREEN", then "NOSCREEN" tutor mode is used. If it is set to "SCREEN", then normal "screen-oriented" tutor mode is used. $TUTOR may be set using the LET command. |
$TUTOPT: | TYPE=STRING COUNT=O:3 DEFAULT=-- VALID=(NO_TAG,NO_NAME, NO_LIBRARY, COMPRESS, NO_SELFTUTOR) $TUTOPT is for tailoring the tutor screen. "NO TAG" suppresses the "Tutor:", "NO NAME", the proc name, and "NO_LIBRARY", the library name on the screen. Setting $TUTOPT to "COMPRESS" requests compressed tutor for all subsequent tutor sessions. All PDFs are treated as if OPTIONS=COMPRESSTUTOR were specified. Setting $TUTOPT to "NO_SELFTUTOR" causes TAE to ignore the OPTIONS=SELFTUTOR in any subsequently invoked proc. This feature exists primarily for testing procs before the proc's self-tutoring logic is working. To set more than one of these qualifiers, include them in a list. For example, LET $TUTOPT=("NO_NAME", "NO_TAG") Note that the $TUTOPT is a nullable vector, so to remove the all of the current settings, set the variable to the null value. LET $TUTOPT = -- |
$USERLIB: | TYPE=(STRING,file-spec-size) COUNT=O:1 DEFAULT=<see below> $USERLIB contains the name of the user library. At the beginning of a session, $USERLIB is automatically set to the library defined by the system manager for the current user. SUSERLIB may be altered during a session in order to change the proc hierarchy search. If $USERLIB is set to the null string, the hierarchy search bypasses the user library. |
By convention, the names of implicit local variables start with the underscore character ("_"). The following local variables are implicitly defined in every proc:
_ONFAIL | TYPE=(STRING, 80) COUNT=1:2 INITIAL="RETURN" _ONFAIL(1) contains the command string to be executed when $SFI is less than zero following execution of a proc. _ONFAIL(2) contains the command string to be executed when the procedure is aborted via the ABORT command from proc interrupt mode. The use of _ONFAIL for exception handling is described in Section 3.5.1. |
_PROC | TYPE=STRING _PROC contains the name of the proc invoked. |
_SUBCMD | TYPE=STRING _SUBCMD contains the name of the active subcommand (fully-spelled and in the same case as the proc's SUBCMD definition). If the subcommand was defaulted on the proc activation command, then the proc's default subcommand is contained in _SUBCMD. |
_STDOUT | TYPE=(STRING, file-spec-size), COUNT=2, INIT=TERMINAL The first element of _STDOUT contains the standard output file name. The second element contains either "APPEND", meaning the current standard output is to be extended, or "CREATE", meaning a new file is to be created. (See Section 2.2.2 for a discussion of standard output.) Note that _STDOUT is set automatically when the STDOUT command qualifier is used. If _STDOUT is set using LET, the results are unpredictable. |
_TUTOR | TYPE=INTEGER When TAE receives an initial tutor request for a proc declared as SELFTUTOR, _TUTOR is set to one, otherwise it is set to zero. |
Variable substitution is the substitution in a command line for a variable by the character string that represents the value of the variable. Substitution always occurs before command interpretation and before variables in expressions are evaluated.
The rules relating to substitution are:
Examples:
The "@" character may be used in a value field of a proc invocation command to indicate "use the value of the following variable." Use of the "@" syntax is called "de-referencing the variable" (because, without the special syntax, the variable name would be taken as a string constant).
The rules associated with de-referencing are:
The differences between substitution and de-referencing are:
IMGCOPY INPUT=@FILE1 OUTPUT=@FILE2
In an "assignment" operation, a FOR or LET command sets the value of a variable to the value of an expression.
Examples:LET X = Y + 8 !Y is a variable FOR VAR = 1,2,3,4 !4 assignments in a loop
The value that is associated with the named variable is the constant produced by the evaluation of the expression.
An expression is a rule for calculating a value based on constants, variables, functions, and operators. TCL provides numeric expressions, string expressions, and logical and relational expressions.
The possible forms of a numeric expression are:
A "term" may be a constant, an integer or real variable, or an integer or real function. A variable or a constant representing a term may be preceded by a unary + or - Spaces are not required between a term and an operator.
A term may not include a multi-valued variable or a variable with the null value. The general operators defined for numeric expressions are:
The unary operators are + and -
See "Evaluation of Expressions," below, for details on the order of evaluation.
Examples of numeric expressions:I + 1 - 1001 X + Y/Z -6 5 * 2.2E-4 *6002 Z (X+Y)/Z I + $FIX(R)
String expressions are used for the concatenation of string constants and/or variables.
The form of a string expression is:
string // string //. . .
The "string" may be a string constant, variable, or function; "//" is the concatenation operator. "String" may not be a multi-valued variable or a variable with the null value.
Examples:
"libe"//".myfile" X//"myfile" "THERE WERE "// "&N" //" IMAGES PROCESSED"
An expression must not contain constants and variables with more than one type except inside relational expressions (Next Section). In addition, the constants and variables on the right-hand side must have the same type as the variable on the left. (Recall that constants of the form 1.0 and 1E3 qualify as valid integers and that 1 is a valid real.)
Functions are available for converting reals to integer and integers to reals. See Section 3.3.5.
Relational expressions provide the capability to perform comparisons between numeric expressions or between string expressions. The result of the evaluation of a relational expression is an integer value with 0 representing false and 1 representing true. The form of a relational expression is:
expression relational-operator expression
The terms in a relational expression may be numeric or string expressions (including numeric or string constants). The relational operators are:
> | greater than
| |
>= | greater than or equal to | |
< | less than
| |
<= | less than or equal to
| |
= | equal to
| |
<> | not equal to |
Multi-valued variables may not be compared using the relational operators. Strings are limited to the "equal" and "not equal" operators; null values are also limited to the "equal" and "not equal" operators.
Real variables can be assigned the result of a relational expression. Mixed-types are allowed across relational operators.
Examples:IF ( x < 3 ) . . . IF ( S = "myname" ) . . . IF ( I >= 3E2 ) . . . IF ( x+y/2 > z*10E6 ) . . . LET x = ( n < 3 )
A logical expression is the logical combination of relational expressions. The form of a logical expression is:
relational-expression logical-op relational-expression...
Logical operators are AND and OR; in addition, a logical expression may be preceded by the logical NOT.
If the operator is AND, the expression is "true" if the relational expressions on both sides of the AND are true, and "false" otherwise.
If the operator is OR, the expression is "true" if either adjacent relational expression is true; "false" if neither is true.
Examples:
IF ( X<3 AND S="myfile" ) . . . IF ( 1<A AND A<10 ) . . . IF ( S="A" OR S="B" OR S="C" ) . . .
The result of a logical expression is an integer value, where 0 represents false and 1 represents true. Logical expressions may be used on the right side of a LET statement for an integer or real variable.
The meaning of "LET X = Y" is that the value associated with the variable X becomes the value that is assigned to the variable Y. If the expression on the right side is not a single variable or a constant, then the expression is evaluated as indicated by the "operator precedence" rules below.
Expression evaluation is left to right, subject to the operator precedence order given in Table 3-3.
unary operators | + -
NOT | |
binary operators | * /
+ - | |
concatenation | // | |
relational operators | < > <> >= <= = | |
logical operators | AND
OR |
By convention, the names of functions start with a dollar sign. A function returns a value and may be treated as a variable. The following rules apply to TCL functions:
The form of a function reference is:
function-name (argument-list)
The argument list is a comma-separated list of values.
Example:
LET X = $FLOAT(I)
The TCL functions are described below.
$FIX converts the argument to an integer, by truncation, and returns the result.
$FLOAT converts the provided argument to a real and returns the result.
$STRLEN returns the length of the specified string.
Arguments:
$COUNT returns the current number of elements for the variable named. If the variable has no value, then $COUNT is -1; if the variable has the null value, then $COUNT is 0.
$GLOBAL returns for the variable named the status of its existence as a global. If the variable is found defined as a global, then $GLOBAL is 1; otherwise, $GLOBAL is 0.
$ASFI returns the current value of $SFI for the asynchronous job.
IMGCOPY |RUNTYPE=ASYNC| LET JOBNAME = $SKEY . . . IF ($ASFI(JOBNAME) > 0) !Success . . .
$ASKEY returns for the asynchronous job named the current value of $SKEY.
$PANEL returns for the named panel the status of its existence. If the panel exists, $PANEL is 1; otherwise, $PANEL is 0.