The COBOL standard specifies an order in which the terms of the conditional expression are evaluated. The standard specifies left-to-right evaluation, and further specifies that evaluation terminates as soon as the value of the conditional expression can be determined.
The practical use of this is a situation wherein if the first term is TRUE the evaluation of the second term might result in a runtime error:
Code:
PERFORM A-PARAGRAPH UNTIL
A-SUBSCRIPT > SUBSCRIPT-LIMIT
OR A-TABLE (A-SUBSCRIPT) = SPACES.
In this example, the COBOL standard requires that A-SUBSCRIPT > SUBSCRIPT-LIMIT, the leftmost boolean term, be evaluated first and, if true, terminate evaluation (because the entire expression will be TRUE) before testing A-TABLE (A-SUBSCRIPT), thereby avoiding a potential runtime problem (referring beyond the last item in a table).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.