Linear procedures and procedures with logic are two ways to run a series of instructions in QMF. Linear procedures contain only QMF commands. Procedures with logic use the full power of REXX within the QMF environment.
Following is an example of a QMF procedure that contains REXX statements.
PROC MODIFIEDLINE1 /* This procedure checks to see what day it is. If it's Monday, it runs a query and prints a report. If it isn't, a message is displayed informing the user. */ signal on error if date('w') = 'Monday' then do "RUN QUERY MYQUERY (FORM = MYFORM" "PRINT REPORT" "MESSAGE (TEXT='OK, MONDAY report has been created and sent to printer.'" end else do "MESSAGE (TEXT='Sorry, it is not Monday. Report cannot be created.'" end exit 0 /*Exit without errors */ error: "MESSAGE (TEXT = '"dsq_message_text"'" exit 8 /*Exit with error condition*/ *** END ***
You can create procedures with logic that include any REXX command or function and make calls to the operating system or other available environments. In a procedure with logic, you can perform conditional logic, make calculations, or pass commands back to the host environment. You can even include both QMF and REXX variables, so you can change the behavior of your procedure without rewriting it. Assign new values to the variables by entering values from the RUN command when the procedure is started, or by prompting the user for input values using REXX Say and Pull statements.
The QMF procedure object helps you automate common tasks. A QMF procedure can contain many different QMF commands. You can run all of the commands in sequence by issuing the RUN PROC command.
Users can be prompted for variable data while running a procedure to customize the results.
Suppose that you need the same type of information or report each week. You can create and save a procedure that uses saved queries, forms, and procedures repeatedly. Or, you can substitute variables to make variations for different results. To make things easier and increase productivity, you can customize a function key to run a procedure with a keystroke.
QMF provides a special procedure that is called a system initialization procedure. It allows you to customize default values that QMF uses and run commands or other procedures automatically when QMF starts up. You can include any QMF command in the system initialization procedure.