Processing Arguments
Developing TACL Routines
107365 Tandem Computers Incorporated
3–9
Processing Arguments Recursively
You can use the #ROUTINENAME built-in function to process arguments recursively.
For more information, see “Calling a Routine Recursively,” later in this section.
Examining the Contents of
Arguments
The following routines examine the contents of arguments. These routines return
results; if you use the routines interactively, use #OUTPUT(V) to display results.
Use the routine in Figure 3-2,
first
, to retrieve a specified number of characters in a
variable. The syntax is:
first
variable number
Figure 3-2. Returning Characters From a Routine
?SECTION first ROUTINE
#FRAME
#PUSH var num
#IF [#ARGUMENT/VALUE var/VARIABLE]
#IF [#ARGUMENT/VALUE num/NUMBER]
#IF [#ARGUMENT END]
== Enclose the following in brackets, in case the result
== contains more than one line
[#RESULT [#CHARGET [var] 1 FOR [num]]]
#UNFRAME
To obtain the contents of a multiple-line variable, enclose your statement in square
brackets. If, for example,
x
contains the following:
abcde
fgh
you can display the contents of
x
(including the line break character at the end of the
first line) with the following statement:
15> [#OUTPUT [first x 9]]
abcde
fgh
16>
The result includes an end-of-line character. For information about #RESULT, see
“Returning Results,” later in this section.
Use the routine in Figure 3-3,
substring
, to retrieve characters from position
number1
to position
number2
of a variable. The syntax is:
substring
variable number1 number2
In this and the following three examples, the #RESULT function call is enclosed in
brackets in case the #CHARGET built-in function returns more than one line.