Controlling Execution

In this section:

Dialogue Manager enables you to manage the flow of execution with these commands:


Top of page

x
Executing Stacked Commands: -RUN

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.



Example: Using the -RUN Command

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:

  1. The command -TYPE sends a message to the client application.
  2. The SQL code is stacked.
  3. The command -RUN sends the stacked commands to the server, which then executes the stacked command and sends the output to the client application.
  4. Processing continues with the line following -RUN. In this case, another message is sent to the client application and a second SQL request is initiated.

Top of page

x
Executing Stacked Commands and Exiting the Procedure: -EXIT

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.



Example: Using the -EXIT Command

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:

  1. The command -TYPE sends a message to the client application.
  2. Assume the value passed to &PROC is REPORT.

    The -IF test checks the value of &PROC. Since it is not equal to UPDATE, control passes to the label -REPORT.

  3. The SQL code is stacked. Control passes to the next line, -EXIT.
  4. The command -EXIT executes the stacked commands. The output is sent to the client application and the procedure is exited.
  5. The SQL request under the label -UPDATE is not executed.

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.


Top of page

x
Canceling Execution: -QUIT

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.



Example: Using the -QUIT Command

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:

  1. The command -TYPE sends a message to the client application. The SQL code is stacked.
  2. Assume that the value of &CODE is B11.

    The command -IF tests the value and passes control to -QUIT.

    The command END is a delimiter.

  3. The command -QUIT cancels execution of the stacked commands and exits the procedure.

iWay Software