Focal Point
Goto Statement Confusions on 7.1.3

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

February 12, 2007, 02:35 PM
Jason K.
Goto Statement Confusions on 7.1.3
Hello!

I'm having trouble understanding how the GOTO statement works. I have written a few GOTO's into my code, and when the called section of code completes, the .fex seems to continue where it left off.

Here is an example of my code:
-IF &REP_GRP_ATTRIB EQ 'FOC_NONE' THEN GOTO MYFASTER ELSE GOTO MYSLOWER;

-MYFASTER
TABLE FILE MATRIX_DIV_MTD
PRINT
STORE_NAME
WHERE RECORDLIMIT EQ 10
END
-GOTO ADD_DETAILS;

-MYSLOWER
TABLE FILE MATRIX_DIV_MONTHLY
PRINT
STORE_CODE
WHERE RECORDLIMIT EQ 10
END
-GOTO ADD_DETAILS;
...
...


The problem is that it outputs the following, which suggests it is running both sections of code even though an IF statement is listed.

PAGE 1
STORE_NAME
05 CNTR-MC
01 WEST
02 CENTRAL
04 HUTCH
01 WEST
04 HUTCH
07 F D-CON
08 F D-C I
20 SALFDMI
21 SAL-F and D

PAGE 1
STORE_CODE
05
01
02
04
01
04
07
08
20
21

I've researched the GOTO statement and it seems as though it is acting like a PERFORM command in my code. I've also added a -GOTOEND in my code, and it still seems to return control to where the GOTO was called.

Please point me in the right direction.
Thanks!


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
February 12, 2007, 03:09 PM
Francis Mariani
Based on my humble WF 5.3.2 knowledge:

1) Ensure that the parameter &REP_GRP_ATTRIB exists.
2) When a Dialogue Manager GOTO statement is not used in an IF statement, do not use the ending semi-colon (i.e. -GOTO ADD_DETAILS).
3) Ensure that the label ADD_DETAILS exists.
4) Add -SET &ECHO=ALL; to see the Dialogue Manager code and the -GOTO statements at work.


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
February 12, 2007, 03:24 PM
Alan B
Just tried on 7.1.3 myself and all works according to plan.

Francis is right in his 2., though 7.1.3 does not seem to object to the semi-colon!
If &REP_GRP_ATTRIB does not exist, I get an error as expected.
If the ADD_DETAILS label does not exist, I get expected error.
So as Francis said, try the &ECHO and let's see the results.


Alan.
WF 7.705/8.007
February 12, 2007, 03:48 PM
Francis Mariani
To ensure that Dialogue Manager branching works correctly, I would add -RUN after the END statements.

-SET &ECHO=ALL;

-IF &DATEYYMD EQ '2007/02/13' GOTO MYONE ELSE GOTO MYTWO;

-MYONE
TABLE FILE CAR
SUM 
COUNTRY
BY COUNTRY
HEADING
"MYONE"
END
-RUN
-GOTO ADD_DET

-MYTWO
TABLE FILE CAR
SUM
MODEL
BY MODEL
HEADING
"MYTWO"
END
-RUN
-GOTO ADD_DET

-ADD_DET
TABLE FILE CAR
SUM
CAR
BY
CAR
HEADING
"ADD_DETAILS"
END
-RUN



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
February 12, 2007, 05:03 PM
Jason K.
Well, I looked into what you folks said. I added the -SET &ECHO=ALL; and it didn't change the output at all. Not sure what to expect, but I assumed some sort of play by play information...all I got was the same HTMl tables. Any ideas appreciated on that.

So, I went ahead and started to question the EQ 'FOC_NONE' part of it, and I changed the value from FOC_NONE to something else, and now it works as expected.

-IF &REP_GRP_ATTRIB EQ 'IGGY' THEN GOTO MYFASTER ELSE GOTO MYSLOWER;

Here's the lousy part, if I can't use FOC_NONE as the variable value, how can I eliminate that part of the where clause? I was counting on the FOC_NONE value to eliminate the where clauses for me. The where criteria gets kinda complex. see below:

WHERE FACILITY_CODE EQ &FACILITY_CODE.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).FACILITY_TEST.;
WHERE STORE_CODE EQ &STORE_CODE.(OR(FIND STORE_CODE IN MATRIX_DIV_MTD)).STORE_TEST.;
WHERE CUST_CLASS_CODE EQ &CUST_CLASS_CODE.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).CUST_CLASS_TEST.;
WHERE CUST_NUMBER EQ &CUST_NUMBER.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).CUST_NUMBER_TEST.;
WHERE PL_NUMBER EQ &PL_NUMBER.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).PL_NUMBER_TEST.;
WHERE GROUP_NUMBER EQ &GROUP_NUMBER.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).GROUP_TEST.;
WHERE SUB_GROUP_NUMBER EQ &SUB_GROUP_NUMBER.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).SUBGROUP_TEST.;
WHERE ITEM_NUMBER EQ &ITEM_NUMBER.(OR(FIND STORE_NAME IN MATRIX_DIV_MTD)).ITEMNUM_TEST.;


If I were to write an -IF statement looking for some other value that represents a FOC_NONE like 'IGGY' for example, it would probably work... but that seems like a really weak solution.

Any ideas?


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
February 12, 2007, 05:39 PM
Trav
When you have -SET &ECHO=ALL then right-click on your output and "view source". That will give you the "play-by-play" details you were expecting.



Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio
Testing: <none>
Using MRE & BID.  Connected to MS SQL Server 2005
Output Types: HTML, Excel, PDF
February 12, 2007, 05:44 PM
Tony A
Jason,

Why bother with the ELSE part? Just have -

-IF &REP_GRP_ATTRIB NE 'FOC_NONE' THEN GOTO MYSLOWER;

That will give you exactly what you are after.

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