Re: IF statement, I don't understand this
- From: Howard Brazee <howard@xxxxxxxxxx>
- Date: Thu, 30 Mar 2006 08:32:07 -0700
On Thu, 30 Mar 2006 06:40:48 -0600, Jack Benny
<pkline@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
000600 01 SHH-SHIP-CODE PIC 9 VALUE 1.
000700 01 ASM010-I-DIR PIC X VALUE "R".
and
001000 IF SHH-SHIP-CODE = 5 AND ASM010-I-DIR = "L" OR "R" OR "S"
001100 DISPLAY "TRUE"
001200 ELSE
001300 DISPLAY "FALSE".
001400 ENDIF.
It comes up "TRUE" and I don't understand why. It doesn't seem right.
First, never code complex and/or statements without parentheses. Even
when you understand what is wanted, don't make things hard for
maintenance programmers who need to not only be sure how the code
works, but also be sure how you intended the code to work.
The problem is, you probably assumed that AND and OR are equal,
processed from left to right. That assumption was wrong. AND had
priority.
.
- Follow-Ups:
- Re: IF statement, I don't understand this
- From: Chuck Stevens
- Re: IF statement, I don't understand this
- References:
- IF statement, I don't understand this
- From: Jack Benny
- IF statement, I don't understand this
- Prev by Date: Re: IF statement, I don't understand this
- Next by Date: Re: IF statement, I don't understand this
- Previous by thread: Re: IF statement, I don't understand this
- Next by thread: Re: IF statement, I don't understand this
- Index(es):
Relevant Pages
|
|