Controlling the Execution of a Procedure

In this section:

You can use Dialogue Manager commands to manage the execution of a procedure. The commands used for this purpose are -RUN, -EXIT, -QUIT, and -QUIT FOCUS.


Top of page

x
Executing Stacked Commands and Continuing the Procedure

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. Following execution of the stacked commands, processing of the procedure continues with the line that follows -RUN.



Example: Executing Stacked Commands and Continuing the Procedure

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:

  1. The first four lines are the report request. Each line is placed on a stack to be executed later.
  2. -RUN causes the stacked commands to be executed. They are sent to the WebFOCUS Reporting Server for processing. Processing continues with the line following -RUN.

Top of page

x
Executing Stacked Commands and Exiting the Procedure

You can execute stacked commands and then exit a procedure with the -EXIT command. -EXIT forces the execution of stacked commands as soon as it is encountered.



Example: Executing Stacked Commands and Exiting the Procedure

In the following, the first report request or the second report request will execute, 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:

  1. Dialogue Manager passes SALES to &PROC.
  2. An -IF test is done, and since the value for &PROC is not EMPLOYEE, the test fails and control is passed to the next line, -SALES.

    If the value for &PROC had been EMPLOYEE, control would pass to -EMPLOYEE.

  3. The FOCUS code is processed, and stacked to be executed later.
  4. -EXIT executes the stacked commands. The output is sent to the WebFOCUS Client application and the procedure is terminated.

    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.


Top of page

x
Canceling the Execution of a Procedure

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 WebFOCUS 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.

In Developer Studio, you can use the -QUIT FOCUS command. This command cancels the execution of a procedure and terminates the FOCUS session. It returns you to the operating system and sets a return code.



x
Syntax: How to Cancel the Execution of a Procedure
-QUIT


x
Syntax: How to Cancel the Execution of a Procedure and Exit FOCUS
-QUIT FOCUS [n]

where:

n

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, a default return code is posted to the operating system, indicating abnormal termination.

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.



Example: Canceling the Execution of a Procedure

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:

  1. The -DEFAULT command sets the default value for &CODE to B11.
  2. The value B11 is passed to &CODE.
  3. The FOCUS code is processed and stacked to be executed later.
  4. -QUIT cancels the execution of stacked commands and exits the procedure.

WebFOCUS