In this section: |
Dialogue Manager enables you to manage the flow of execution with these commands:
The Dialogue Manager command -RUN causes immediate execution of all stacked commands and closes any external files opened with -READ or -WRITE. Following execution, processing of the procedure continues with the line that follows -RUN.
The following example illustrates the use of -RUN to execute stacked SQL code and then return to the procedure.
1. -TYPE This report calculates percentage of returns. 2. SQL . . . END 3. -RUN 4. -TYPE This routine adds data to the sales file. SQL . . .
The procedure processes as follows:
Like the -RUN command, the Dialogue Manager command -EXIT forces execution of stacked commands as soon as it is encountered. However, instead of returning to the procedure, -EXIT closes all external files, terminates the procedure, and exits. If the procedure that is processing was called by another procedure, control returns to the calling procedure.
In the following example, either the first SQL request or the second SQL request executes, but not both.
1. -TYPE This report calculates percentage of returns. 2. -IF &PROC EQ 'UPDATE' GOTO UPDATE; 3. -REPORT SQL . . . END 4. -EXIT 5. -UPDATE SQL . . . END
The procedure processes as follows:
The -IF test checks the value of &PROC. Since it is not equal to UPDATE, control passes to the label -REPORT.
This example also illustrates an implicit exit. If the value of &PROC were UPDATE, control would pass to the label -UPDATE after the -IF test, and the procedure would never encounter the -EXIT. The second SQL request would execute and the procedure would automatically terminate.
The Dialogue Manager command -QUIT cancels execution of any stacked commands and causes an immediate exit from the procedure. If the procedure that is processing was called by another procedure, control returns directly to the client application, not to the calling procedure.
This command is useful if tests or computations generate results that make additional processing unnecessary.
The following example illustrates the use of -QUIT to cancel execution based on the results of an -IF test.
1. -TYPE This report calculates percentage of returns. SQL . . . 2. -IF &CODE GT 'B10' OR &CODE EQ 'DONE' GOTO QUIT; END 3. -QUIT
The procedure processes as follows:
The command -IF tests the value and passes control to -QUIT.
The command END is a delimiter.
iWay Software |