Using macros, you can maximize the usefulness of your procedures and avoid the need to create new procedures whenever parameters change. Macros give you the flexibility to produce customized output using a single procedure.
For example, you can create a procedure called “Export_L” to extract records and export the data to a Lotus 1-2-3™ file:
OPEN %INPUT%
EXTRACT RECORD IF %FIELD%>%CUTOFF% TO TEMP
OPEN TEMP
EXPORT ALL LOTUS TO %OUTPUT%
CLOSE
Export_L expects four variables to be defined: INPUT, FIELD, CUTOFF and OUTPUT. To run the procedure, define the variables before the Do Procedure command.
INPUT='DEMO'
OUTPUT='TEST1'
FIELD='AMOUNT'
CUTOFF=1000000
DO EXPORT_L
You can also use macros to specify default values in interactive procedures. For example, you can include an Accept command to ask you to enter the file name.
INPUT='DEMO'
OUTPUT='TEST1'
FIELD='AMOUNT'
CUTOFF='1000000'
ACCEPT "Enter the file name:" TO INPUT
DO EXPORT_L
Because a file name has already been assigned (INPUT='DEMO'), if you fail to provide a name, the specified value DEMO is used.