Returning Results
Developing TACL Routines
107365 Tandem Computers Incorporated
3–15
Returning Results
Function results come from one or more #RESULT built-in functions within the
routine. This is an important distinction between macros and routines: a macro
invocation returns the expansion of the text of the macro; a routine returns only what
the #RESULT function provides.
Use the macro in Figure 3-9,
report_shell
, to calculate today’s date and the date
thirty days ago and convert the dates to SQL format (yyyy-mm-dd). This example is
similar to Figure 2-10, but returns results. To run this macro, load the associated file
and enter:
report_shell
Figure 3-9. Converting Timestamps
?SECTION report_shell MACRO
#FRAME
#PUSH #OUTFORMAT #INFORMAT today
#SET #OUTFORMAT PRETTY
#SET #INFORMAT TACL
== Calling part of Macro
#OUTPUT This macro displays a start and end date.
#SETMANY today, [get_dates]
#OUTPUT
#OUTPUT The date is [today]
#UNFRAME
?SECTION get_dates ROUTINE
#FRAME
== Save the current setting of #OUTFORMAT,
== so that it can be restored later:
#PUSH #OUTFORMAT #INFORMAT
[#PUSH
date == starting date (30 days ago)
yyyy == year
mm == month
dd == day
]
#SET #OUTFORMAT PRETTY
== Get the date and convert to yyyy mm dd calendar format:
#SETMANY yyyy mm dd, [#CONTIME [#TIMESTAMP]]
== Store as yyyy-mm-dd format (SQL date format):
#SET date [yyyy]-[mm]-[dd]
== Return the result to the caller.
#RESULT [date]
#UNFRAME