×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

COBOL General discussion FAQ

Conditionals

Does order matter in conditional expressions? by k5tm
Posted: 7 Mar 02

Yes, it can matter.

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:

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

Back to COBOL General discussion FAQ Index
Back to COBOL General discussion Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close