bdfs1m0lStructured Programming Macros

Processing Rules for Boolean Connectors

The overall processing sequence is as follows:

  1. Processing in a group is from left to right and top to bottom.
  2. Conditional expression groups are processed from left to right.

    The sequence of evaluation in a group is as follows:

  3. If a test in a group is true and it is followed by an OR connector, the whole group is true.
  4. If a test in a group is false and it is followed by an AND connector, the whole group is false.

    Note:
    This is not strict Boolean logic, so it is necessary to force the sequence of evaluation.

    For example, the expression A AND B OR C is evaluated in Boolean logic as (A AND B) OR C.

    To ensure that the expression is evaluated unambiguously, one of the following solutions is required:

    1. Force two groups.
        A AND B ORIF C
      
    2. Ensure that the C is not ignored.
        C OR A AND B
      

    The sequence of evaluation between groups is as follows:

  5. If a group followed by an ORIF connector is true, the group following the next ANDIF connector (if present) is checked.
    Note:
    This is not strict Boolean logic.
  6. If a group followed by the ANDIF connector is false, the group following the next ORIF connector (if present) is checked.
  7. Each ORIF connector must be preceded by either an AND connector or an ANDIF connector; otherwise, it has no grouping effect and functions as a normal OR connector.
  8. Each ANDIF connector must be preceded by either an OR connector or an ORIF connector; otherwise, it has no grouping effect and functions as a normal AND.

    For example, the test:

      A and (B or C)
    

    is coded as:

      B OR C ANDIF A
    

    to force two groups.

Evaluating Concatenated Expressions

As a summary of the processing rules described previously, Table 6 and Table 7 show the steps that are used to evaluate an expression based on whether the connector is AND, ANDIF, OR, or ORIF.

Table 6. Decision Table: Boolean Expression Evaluation for AND or ANDIF

Connected by AND or ANDIF? Left Expression True? Expression Followed by ORIF? Result
Yes Yes Yes or No Test the next conditional expression.
Yes No Yes Test the expression after the next ORIF.
Yes No No The whole conditional expression is FALSE.

Table 7. Decision Table: Boolean Expression Evaluation for OR or ORIF

Connected by OR or ORIF? Left Expression True? Expression Followed by ANDIF? Result
Yes Yes Yes Test the expression after the next ANDIF.
Yes Yes No The whole conditional expression is TRUE.
Yes No Yes or No Test the next conditional expression.

Boolean Expression Examples

The code that is required to check the format of an input field is a good example of where problems can occur in concatenating tests.