An example procedure with logic
This example procedure with logic automatically prints a report on a particular day.
About this task
Procedures with logic can run both QMF and REXX commands. The rules and the structure of procedures with logic follow the rules of any REXX program.
- Create and save the query and form.
The PROC panel displays.
- Type a REXX comment
line as the first line of the procedure so that QMF recognizes
the procedure as a procedure with logic. REXX comment lines begin with
and end with
. The first line of a procedure must be a comment, but you can also use them anywhere to explain the commands in the procedure.
- Type the QMF commands
that you want the procedure to run in the order you want them to run.
Because QMF does not convert any text in a procedure, type all QMF commands in uppercase or they will not run.
Enclose all QMF commands in quotes to distinguish them from REXX commands; any QMF command that is identical to a REXX command (such as EXIT) is processed as a REXX command.
If you want to display and interact with panels just as you would if you entered a command on the QMF command line, type
INTERACTbefore the command name.
- Type the logic statements for the procedure. You can use any REXX function in a procedure with logic.
You can also include internal functions for arithmetic operations, character manipulation, data conversion, and information gathering, and you can write your own external functions.
- Type a REXX exit
statement at the end of the procedure. The procedure in the following figure has two exit statements. One has an exit code of 0, meaning that the procedure ran successfully. The other has a return code of 8, meaning that an error occurred while the procedure was running. The procedure uses the QMF MESSAGE command to issue message text to help users diagnose the error.
- To insert lines in a procedure, move the cursor to the
line you want to precede the new line, and press the Insert function
You can also type INSERT on the QMF command line, move the cursor to the line you want to precede the new line, and press Enter.
- To delete lines from a procedure, move the cursor to the
line you want to delete and press the Delete function key.
Alternatively, you can type DELETE on the QMF command line, move the cursor to the line you want to delete, and press Enter.
- To save the procedure in the database, enter:
SAVE AS procname
In the procedure that is shown in the previous figure, the REXX DATE function provides the day of the week. The rest of the procedure includes QMF commands that are run depending on the day of the week.