
Processing Arguments
Developing TACL Routines
3–10
107365 Tandem Computers Incorporated
Figure 3-3. Returning a Set of Characters From a Variable
?SECTION substring ROUTINE
#FRAME
#PUSH bgn end var
#IF [#ARGUMENT/VALUE var/VARIABLE]
#IF [#ARGUMENT/VALUE bgn/NUMBER]
#IF [#ARGUMENT/VALUE end/NUMBER]
#IF [#ARGUMENT END]
[#RESULT [#CHARGET [var] [bgn] TO [end]]]
#UNFRAME
Note
This routine does not check to make sure that
number2
is a greater number than
number1
. For
more thorough argument validation, include that check.
Use the routine in Figure 3-4,
scan
, to scan for text and retrieve the first position,
starting at a specified position, where the text occurs in the variable. The syntax is:
scan
variable number text
Do not enclose
text
in double quotes unless the quotes are part of the text.
Figure 3-4. Searching for Text
?SECTION scan ROUTINE
#FRAME
#PUSH var num txt
#IF [#ARGUMENT/VALUE var/VARIABLE]
#IF [#ARGUMENT/VALUE num/NUMBER]
#IF [#ARGUMENT/VALUE txt/TEXT]
#IF [#ARGUMENT END]
[#RESULT [#CHARFINDV [var] [num] txt]]
#UNFRAME
Note
If you do not include square brackets around the variable names in the #CHARxxx calls, TACL uses the
declared variables (
var
and
num
) instead of the variables passed to the routine and referenced by
var
and
num
.
Use the routine in Figure 3-5,
length
, to retrieve the number of characters in a
variable (including end-of-line characters). The syntax is:
length
variable