Processing Arguments
Developing TACL Routines
3–2
107365 Tandem Computers Incorporated
To process the f
ile-name
argument from a macro:
?SECTION process_argm MACRO
== This macro does not check argument type or validity.
== Separate coding is required to validate the argument.
#FRAME
#PUSH fname
== Store the first argument in fname.
#SET fname %1%
#OUTPUT File name is [fname]
#UNFRAME
To process the
file-name
argument from a routine:
?SECTION process_argr ROUTINE
== This routine checks for correct file name syntax and
== existence of the named file.
#FRAME
#PUSH fname rslt
== Check to see if the first argument is a valid file name
== for an existing file. If so, store it in fname.
#SET rslt [#ARGUMENT /VALUE fname/ FILENAME OTHERWISE]
[#IF rslt = 1 |THEN| == valid filename
#OUTPUT File name is [fname]
|ELSE|
#OUTPUT *** Invalid filename ***
]
#UNFRAME
Note
The OTHERWISE alternative allows you to handle invalid arguments within your program.
#The routine performs more error checking. If, the user does not supply an argument,
or if the file does not exist, the routine returns an error. In contrast, the macro
continues with an invalid file name.
The resulting argument text may be different between macros and routines. In the
previous example, the macro outputs exactly what it was given:
39> process_argm thisfile
File name is thisfile
The routine, because of the VALUE option in the #ARGUMENT call, returns the fully
qualified file name. For example:
40> process_argr thatfile
File name is \NODE.$VOL.SUBVOL.THATFILE