PS TEXT FORMAT Reference Manual
Examples of Function and Macro Constructs
G-2 11387 Tandem Computers Incorporated
FUNCTION Example 1 Let’s start with a simple function where you use TFORM system variables.
Remember, you cannot assign values directly to these variables—TFORM
assigns the appropriate values when you use them. This example returns
the number of lines used on a text page up to the point where this function
is executed:
\FUNCTION tsize BEGIN
\ RETURN SYS_textarealength/SYS_lineheight
\ENDFUNCTION tsize
The value of the expression in the RETURN statement becomes the value of
the function.
FUNCTION Example 2 This example uses the TFORM system-supplied functions FIND and
STRING and the system-supplied variable SYS_filename. This function
strips volume and subvolume names from source file names:
\FUNCTION thisfile BEGIN LOCAL fnloc
\ ASSIGN fnloc FIND(SYS_filename,".",FIND(SYS_filename,"."))
\ RETURN STR(SYS_filename, fnloc)
\ENDFUNCTION thisfile
FUNCTION Example 3 This example uses the TFORM system-supplied functions ARG and
SELECT. This is a user function designed to evaluate the number of days
that have passed between two specified days. The function is named span.
The construct itself is shown first, and then an example using the function
follows.