PDA

View Full Version : boolean logic within an IF statement



Guest.Visitor
09-17-2002, 12:14 PM
Hi Jim. I believe your example will perform the FIELD1 = 'R', regardless of the value of FIELD2 and FIELD3. It looks like the FIELD2 and FIELD3 are only tested when FIELD1 = 'V'. Since you want the operation to occur on field 1, you have to quantify the logic do so. See the example below. -Mean 1 <hr width=50 align=left>Code ('http://www.mcpressonline.com/mc/showcode@@.6ae3cc24/1')

rdean400@yahoo.com
09-17-2002, 12:15 PM
Free form would look like this:</P> <PRE><TT> If ((Field1 = 'R') Or (Field1 = 'V')) And (Field2 = 'A') And (Field3 = 'V'); </TT></PRE> In RPG III, I'd nest the IF's: <PRE><TT> FIELD1 IFEQ 'R' FIELD1 OREQ 'V' FIELD2 IFEQ 'A' FIELD3 ANDEQ 'V' ... ENDIF ENDIF </TT></PRE> Robert

Guest.Visitor
09-17-2002, 12:18 PM
Jim - Doesn't look right to me. The ANDs are processed before the OR, so your proposed change will look at Field2 and Field3 only if Field1 = 'V'. If Field1 = 'R' it will return True regardless of what's in Fields 2 and 3. I think the best solution is below: Bill <hr width=50 align=left>Code ('http://www.mcpressonline.com/mc/showcode@@.6ae3cc24/3')

vin@planetchan.com
09-17-2002, 06:37 PM
Mighty good reason to convert the prog to RPGILE isn't it?

Guest.Visitor
09-18-2002, 02:56 PM
Thank you very much !!!

Guest.Visitor
09-18-2002, 02:56 PM
Thank you Robert !!

Guest.Visitor
09-18-2002, 02:58 PM
Thank you Bill !!!

Guest.Visitor
09-18-2002, 02:59 PM
To whom it may concern, I have to make a change to an RPG program that has the following IF statement in it....... FIELD1 IFEQ 'R' FIELD2 ANDEQ 'A' FIELD3 ANDEQ 'V' I need to add code so that when FIELD1 = 'V', the program does the same thing it does when FIELD1 = "R'. Here is what I propose to change the IF statement to...... FIELD1 IFEQ 'R' FIELD1 OREQ 'V' FIELD2 ANDEQ 'A' FIELD3 ANDEQ 'V' Does this look right ? Or do I need to make a brand new IF statement just for FIELD1 = 'V' ? Thank you !! Jim Sovick

Guest.Visitor
09-18-2002, 02:59 PM
Hi Vincent, No kidding. I am for sure going to do that !! Have a good one. Jim