I have a question concerning the use of parenthesis in IF statements in COBOL.
Let's say we have :
05 SHIRT-COLOR PIC X(02).
88 BLUE-SHIRT VALUE 'B '.
88 WHITE-SHIRT VALUE 'W '.
I would like to know if there is a difference between :
IF BLUE-SHIRT OR WHITE-SHIRT
and
IF (BLUE-SHIRT OR WHITE-SHIRT)
Will the two IF statements give the same result or not?
Thank you for your answer :)
Indeed the parentheses make no difference, but it is perhaps important to understand what is going on here semantically and syntactically.
In COBOL the IF
statement expression is not enclosed in parentheses. However an expression may use parentheses to force a particular evaluation order. So in this case it is simply an expression with redundant parentheses. That is to say the expressions:
(BLUE-SHIRT OR WHITE-SHIRT)
and
BLUE-SHIRT OR WHITE-SHIRT
that are semantically identical and the IF
is irrelevant.