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     [SOLVED] IF ELSE SYNTAX ERROR

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] IF ELSE SYNTAX ERROR
 Login/Join
 
Member
posted
i am using the following if else statement
-SET &w = IF &Text.&I.A150 CONTAINS "some text"
THEN PRINT "hello"
ELSE PRINT "helloq1";

i dont understand what is the error
its giving IF ..THEN..ELSE synatx error
please help

This message has been edited. Last edited by: <Kathryn Henning>,


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Expert
posted Hide Post
I won't debug the rest of the -SET statement, but since it is a multi-line Dialogue Manager command, each subsequent line must begin with "- ".

-SET &w = IF &Text.&I.A150 CONTAINS "some text"
- THEN PRINT "hello"
- ELSE PRINT "helloq1";


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
I don't think you can declare the size of an amper variable. Furthermore, you are using an indexed variable. Does &I have a value?

Please declare &I=1; and remove A150. Then try it and see what happens. Also put -SET &ECHO=ALL at the very top of your code to observe this result in detail.
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Master
posted Hide Post
On the other hand, I might be crazy.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Member
posted Hide Post
Thanks for the reply Francis , but i am still having the same error

&Text.&I.A80 = "TEXt TEXT TEXT some text TEXT TEXT"

can i use the below condition

-SET &w = IF &Text.&I.A150 CONTAINS "some text"
-THEN PRINT "hello"
-ELSE PRINT "helloq1";

ERROR MESSAGE :-
0 ERROR AT OR NEAR LINE 29 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Virtuoso
posted Hide Post
PRINT in that context is new to me. Is that correct syntax?

For giggles remove the two PRINTs. That's what I would have done. Should set &w to the correct value.

What does it look like in the code with the amper-variables resolved by the way? -SET ECHO=ALL at the top and show us what the command going to the parser looks like.

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



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Master
posted Hide Post
Instead of the print command where you've coded put GOTO PrintIt. The code a -PrintIt label, where you'd code the print XXX command, followed by -EXIT to leave the program.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Member
posted Hide Post
i have written the following program

-SET &MAS_COUNT = &LINES;
-REPEAT :MAS_READ FOR &I FROM 1 TO &MAS_COUNT;
-READ mymaster &Text.&I.A80
-SET &w = IF &Text.&I CONTAINS "sometext"
-THEN GOTO Printit
-ELSE GOTO REPEAT;
-*IF &IORETURN NE 0 THEN GOTO END_READ;
-TYPE text =&Text.&I.A80
-:MAS_READ

-Printit
PRINT "Hello"
-EXIT

If it dosent match i want to continue the looping


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Expert
posted Hide Post
It looks like your ELSE statement does not have "- " before it.

And PRINT is not a Dialogue Manager command.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Master
posted Hide Post
Below the -PrintIt section you have only 2 options for output....
1. Issue a table request to print a report, or
2. Issue a -TYPE &variable . Or, -TYPE Hello

Basically as Francis just stated.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Member
posted Hide Post
i have written the following program

-SET &MAS_COUNT = &LINES;
-REPEAT :MAS_READ FOR &I FROM 1 TO &MAS_COUNT;
-READ mymaster &Text.&I.A80
-SET &w = IF &Text.&I CONTAINS "sometext" THEN GOTO Printit ELSE GOTO REPEAT;
-*IF &IORETURN NE 0 THEN GOTO END_READ;
-TYPE text =&Text.&I.A80
-:MAS_READ

-Printit
-TYPE hello
-EXIT

My question is is the IF statement correst?? can i issue GOTO REPEAT in the ELSE ??

As my Error is

0 ERROR AT OR NEAR LINE 29 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC266) IF .. THEN .. ELSE .. SYNTAX ERROR

My line 29 is -SET &w = IF &Text.&I CONTAINS "sometext" THEN GOTO Printit ELSE GOTO REPEAT;


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Master
posted Hide Post
What do you with the &w variable? It seems to me you should code: -IF &text.&I eq ... Then GOTO ...ELSE ...


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Member
posted Hide Post
SET &w = IF &Text.&I CONTAINS 'sometext' THEN GOTO Printit ELSE GOTO REPEAT;

I have used single codes instead of double and it worked..


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Expert
posted Hide Post
You shouldn't do a -SET when using an IF THEN ELSE with GOTO's, it is illogical.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
It's apparent the Dialog Manager directive you are looking for is
-IF ... ;

rather than
-SET ... ;


Look it up.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
yes j.gross, i have corrected it and works fine..thanks


WEBFOCUS 8.0
 
Posts: 21 | Registered: July 08, 2015Report This Post
Master
posted Hide Post
I'm with Waz. You should use the value in &w as the value for the GOTO:

-SET &w = IF &Text.&I CONTAINS 'sometext' THEN 1 ELSE 0;
-IF &w EQ 1 GOTO Printit ELSE GOTO REPEAT;

Jack, as usual, has the more succinct version. Mine works if you want to use &w elsewhere.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Master
posted Hide Post
There are several good examples here for you to follow, but here is an approach I've coded in the past.

To accommodate your use of the &W variable...

-SET &W = IF &AGE LE 100 THEN YOUNG ELSE OLD;
-GOTO &W

-YOUNG
-**** DO SOMETHING WITH THE YOUNG
ETC.
-GOTO OUTT

-OLD
-**** DO SOMETHING WITH OLD
ETC.

-OUTT
-EXIT

Another, perhaps with less coding...

-IF &AGE LE 100 THEN GOTO YOUNG ELSE IF &AGE GT 100 GOTO OLD;

Use the -YOUNG and -OLD code I created above

Good Luck


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 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     [SOLVED] IF ELSE SYNTAX ERROR

Copyright © 1996-2020 Information Builders