In this section: |
You can use Dialogue Manager commands to manage the execution and termination of a procedure. The commands used for these purposes are EXEC, -RUN, -EXIT, -QUIT, and -QUIT FOCUS.
How to: |
Procedures are generally initiated from the FOCUS prompt (>). Type the EXEC command followed by the name of the procedure to run.
If you wish to supply arguments for the procedure, see Supply a Variable Value on the Command Line.
You can execute a single procedure or call and execute one procedure from within another one. For details, see Calling Another Procedure With EXEC.
EX[EC] procedure
where:
Is the name of the procedure.
To summon a procedure named SLRPT for execution, enter either:
EXEC SLRPT
or
EX SLRPT
You can execute stacked commands and continue the procedure with the -RUN command.
The -RUN command causes immediate execution of all stacked commands and closes any external files opened with -READ or -WRITE. For related information, see Reading Variable Values From and Writing Variable Values to an External File.
Following execution of the stacked commands, processing of the procedure continues with the line that follows -RUN.
The following illustrates the use of -RUN to execute stacked code and then return to the procedure. The numbers to the left correspond to the notes explaining the code.
1. TABLE FILE SALES PRINT PROD_CODE UNIT_SOLD BY CITY END 2. -RUN TABLE FILE EMPLOYEE PRINT LAST_NAME FIRST_NAME BY DEPARTMENT END
The procedure processes as follows:
You can execute stacked commands then exit a procedure with the -EXIT command. -EXIT forces the execution of stacked commands as soon as it is encountered.
-EXIT closes all external files, terminates the procedure, and returns to the FOCUS prompt unless the procedure was called by another procedure, in which case control returns to the calling procedure. For related information, see Calling Another Procedure With EXEC.
In this example, the first report request or the second report request executes, but not both.
1. -SET &PROC = 'SALES'; 2. -IF &PROC EQ 'EMPLOYEE' GOTO EMPLOYEE; -SALES 3. TABLE FILE SALES SUM UNIT_SOLD BY PROD_CODE END 4. -EXIT -EMPLOYEE TABLE FILE EMPLOYEE PRINT LAST_NAME BY DEPARTMENT END
The procedure processes as follows:
If the value for &PROC had been EMPLOYEE, control would pass to ‑EMPLOYEE.
The request under the label -EMPLOYEE is not executed.
This example also illustrates an implicit exit. If the value of &PROC was EMPLOYEE, control would pass to the label -EMPLOYEE after the -IF test, and the procedure would never encounter -EXIT. The TABLE FILE EMPLOYEE request would execute and the procedure would automatically terminate.
How to: |
You can cancel the execution of a procedure with the -QUIT command. -QUIT cancels execution of any stacked commands and causes an immediate exit from the procedure. Control returns directly to the application regardless of whether the procedure was called by another procedure.
This command is useful if tests or computations generate results that make additional processing unnecessary.
You can use a variation, -QUIT FOCUS, to cancel the execution of a procedure and terminate the FOCUS session. It returns you to the operating system and sets a return code.
-QUIT
-QUIT FOCUS [n|8]
where:
Is the operating system return code number. It can be a constant or variable. A variable should be an integer. If you do not supply a value or if you supply a non-integer value, the return code posted to the operating system is 8 (the default).
A major function of user-controlled return codes is to detect processing problems. The return code value determines whether to continue or terminate processing. This is particularly useful for batch processing. For related information, see Testing the Status of a Query.
The following example illustrates the use of -QUIT to cancel execution based on the results of an -IF test:
1. -DEFAULT &CODE='B11'; 2. -IF &CODE EQ '0' OR &CODE EQ 'DONE' GOTO QUIT; 3. TABLE FILE SALES SUM UNIT_SOLD WHERE PROD_CODE EQ &CODE END 4. -QUIT
The procedure processes as follows:
How to: |
Users can respond to a Dialogue Manager value request with QUIT and return to the FOCUS command level or the prior procedure. In situations where it is important to prevent users from entering native FOCUS or QUIT from a particular procedure, the environment can be locked and QUIT deactivated.
Enter the following command within the procedure:
-SET &QUIT=OFF;
With QUIT deactivated, any attempt to return to native FOCUS produces an error message indicating that "quit" is not a valid value. The user is prompted for another value.
A user can terminate the FOCUS session from inside a locked procedure by responding to a prompt with
QUIT FOCUS
to return to the operating system, not the FOCUS command level.
Note: The default value for &QUIT is ON.
|
Information Builders |