Focal Point
[SOLVED] How to code for compound IF logic

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5761069772

March 27, 2008, 10:11 AM
webmeister
[SOLVED] How to code for compound IF logic
I haven't been able to find info on how to code compound IF logic. Is code like the following valid?

FIELDB /P5 = IF (FIELDA GE 1 AND FIELDA LE 500) THEN FIELDA ELSE 0;

If that is not valid, then what is a valid way to code for something like this?

Thanks so much!

This message has been edited. Last edited by: webmeister,


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
March 27, 2008, 10:18 AM
PBrightwell
That should be valid, you don't even need the parens. Are you having a problem with it?


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
March 27, 2008, 10:41 AM
Leah
As Pat asked, are you having a problem, is this in a COMPUTE or DEFINE? You can also use the syntax IF FILEDA FROM 1 TO 500 THEN FIELDA ELSE 0.


Leah
March 27, 2008, 10:50 AM
webmeister
Thank you all for replying! I originally had code like this:

FIELDB /P5 = IF FIELDA (GE 1 AND LE 500) THEN FIELDA ELSE 0;

That didn't work, so I then had code like this:

FIELDB /P5 = IF (FIELDA GE 1 AND FIELDA LE 500) THEN FIELDA ELSE 0;

which also did not work, so I then wanted to try the IS_FROM logic, which does appear to work. I'll also try your suggestion, Leah.

Thanks so much again for replying and so quickly!


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
March 27, 2008, 11:15 AM
Tony A
No such thing as IS_FROM logic, perhaps you mean this -

FIELDB/P5 = IF FIELDA FROM 1 TO 500 THEN FIELDA ELSE 0;

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 27, 2008, 11:38 AM
PBrightwell
webmeister,
I just assumed that your code was in a define, if it is a compute the word COMPUTE is missing. If it is in a define what you have should work, assuming that FIELDA is numeric.

This message has been edited. Last edited by: PBrightwell,


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
March 27, 2008, 12:33 PM
Tony A
I'll occasionally use boolean logic instead of compund IFs -
FIELDB/P5 = (FIELDA FROM 1 TO 500) * FIELDA;

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10