Processing Arguments
Developing TACL Routines
107365 Tandem Computers Incorporated
3–11
Figure 3-5. Counting Characters in a Variable
?SECTION length ROUTINE
#FRAME
#PUSH var
#IF [#ARGUMENT/VALUE var/VARIABLE]
#IF [#ARGUMENT END]
[#RESULT [#CHARCOUNT [var]]]
#UNFRAME
Use the routine in Figure 3-6,
insert
, to insert the contents of
variable1
into
variable2
at the specified position. The syntax is:
insert
variable1 variable2 number
Figure 3-6. Moving Text Between Variables
?SECTION insert ROUTINE
#FRAME
#PUSH var1 var2 num
#IF [#ARGUMENT/VALUE var1/VARIABLE]
#IF [#ARGUMENT/VALUE var2/VARIABLE]
#IF [#ARGUMENT/VALUE num/NUMBER]
#IF [#ARGUMENT END]
[#RESULT [#CHARINSV [var2] [num] [var1] ]]
#UNFRAME
Parsing Arguments for a
Caller
You can use the #ARGUMENT built-in function to provide a general parser for other
TACL programs. Figure 3-7 contains two sample programs:
getargs
, a macro that parses arguments for a routine that calls it and returns the
value in a variable (the calling program supplies a name)
call_getargs
, a routine that calls
getargs
Note
Getargs
is defined as a macro, and can be used only when called by a routine. Otherwise, the
#ARGUMENT call inside the macro is not valid.