Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Using OR in IF THEN ELSE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Using OR in IF THEN ELSE
 Login/Join
 
Gold member
posted
Can we do something like this using IF

If &TEST EQ '1' or '2' or '3' then "Red"
ELSE If &TEST EQ '4' or '5' or '6' then "Yellow"

Thank you


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Virtuoso
posted Hide Post
quote:
If &TEST EQ '1' or '2' or '3' then "Red"
ELSE If &TEST EQ '4' or '5' or '6' then "Yellow"

Thank you



Do it all the time in defines, what are you trying to do? ((of course or is OR) sorry couldn't resist).


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Virtuoso
posted Hide Post
and it doesn't hurt to use parentheses to clarify. I've found that sometimes WF likes it better as well.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Gold member
posted Hide Post
Leah,

It worked, there was a syntax error.

Darin,

I will try to do that.

Thanks much.


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Virtuoso
posted Hide Post
If this is a DEFINE/COMPUTE, the syntax would be:
fld/A10 = IF '&TEST' EQ '1' OR '2' OR '3' THEN 'Red'
     ELSE IF '&TEST' EQ '4' or '5' or '6' THEN 'Yellow' 
     ELSE 'defaultValue';

And because I am not a fan of 'lazy' OR processing, another approach:
fld/A10 = IF '1,2,3' CONTAINS '&TEST' THEN 'Red'
     ELSE IF '4,5,6' CONTAINS '&TEST' THEN 'Yellow' 
     ELSE 'defaultValue';

If it is DM,
-SET &fld = IF &TEST EQ '1' OR '2' OR '3' THEN 'Red'
-      ELSE IF &TEST EQ '4' or '5' or '6' THEN 'Yellow' 
-      ELSE 'defaultValue';

or
-SET &fld = IF '1,2,3' CONTAINS &TEST THEN 'Red'
-      ELSE IF '4,5,6' CONTAINS &TEST THEN 'Yellow' 
-      ELSE 'defaultValue';

or
-SET &fld = DECODE &TEST(1 Red 2 Red 3 Red 4 Yellow 5 Yellow 6 Yellow ELSE default);

Always supplying a value if the tests fail, the last ELSE.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Gold member
posted Hide Post
Alan,

quote:
Always supplying a value if the tests fail, the last ELSE


I did this mistake and figured out later.

Just curious, are there any advantages of decode vs IF ?

Thank you for the syntax.

KK


Test - Webfocus 7.6.7
Prod - Webfocus 7.6.7
Win2003
Sql Server 2000 and 2008
 
Posts: 59 | Registered: May 01, 2007Report This Post
Master
posted Hide Post
Since DECODE is essentially a nested IF...THEN...ELSE statement, you can test a lot more values with DECODE. Nested IF used to have a limit of 16 but I think is higher now. DECODE has the option of using a file with a size limit of 32K (which might be higher now), which depending of the size of the data, allows the testing of hundreds of values. Back in early day of PC FOCUS where memory usage could be critical, if I remember correctly, DECODE uses less memory than nested IF statements.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Using OR in IF THEN ELSE

Copyright © 1996-2020 Information Builders