Conditional Entry to a Procedure

Before executing subsidiary procedures, QA Build tests the return_value of the calling procedure. Under some circumstances, for example if the user pressed <Esc> in an interactive procedure body, or a batch access database procedure ran out of records to process, execution leaves that part of the procedure tree. Also if a database procedure deleted a record or if a record could not be found, or a database update failed, subsidiary procedures will not normally be executed. You can force subsidiary procedures to be executed in some additional cases using the Error Subsidiaries option in the procedure overview. For more information on how QA Build decides whether to execute subsidiaries refer to Procedure Execution.

In addition to this built-in processing, you can specify your own conditions to determine whether a particular subsidiary procedure should be executed, using a Condition to Enter set up in the Link dialog.

The condition to enter follows the logic:

  if (the condition to enter is satisfied) then 
    execute procedure.

For procedures with a repeated procedure body you should note that the Entry Condition is only tested on initial entry into the procedure, and not before the procedure obdy is repeated.

For menus and action bars the entry conditions of all the subsidiary procedures are tested when the menu is displayed. This is done so that there is a visible indication of which options are not available. This is called greying out, and is explained in more detail in Menu Options.

To set up a condition to enter:

  1. In the Program flow diagram select the node in the procedure
  2. Select the Link option on the Program Flow action bar
  3. Move to the condition to enter and follow the instructions press E to edit a condition

Note that the condition to enter is a property of the calling procedure and not of the subsidiary itself - the same procedure can appear in different places in a procedure tree with different conditions to enter each time. Also the condition will be preserved if the procedure body used by the calling procedure is changed.



Useful variables

Two of QABs standard variables may be useful when creating conditions to enter:

option_nr

Provides the return value from the calling procedure's procedure body

last_return_value 

Provides the return value from the last procedure body executed. This is particularly useful where you want to test the return value of the procedure on the left (assuming it did not have any subsidiaries).