Focal Point
[SOLVED] dynamic GOTO

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

November 05, 2013, 11:44 AM
Piter
[SOLVED] dynamic GOTO
Hi

have anybody made a trick for situation when you have many occurrences of same code and like to put them into one separate fex and use -INCLUDE?

I know that many of us had this Smiler

But how to solve situation if inside of this "replicated" code you have -GOTO label sentence.

I have tried to do something like

Main code:

-SET &I=1
-INCLUDE FUNCTION_AA
... some code of main program ...
-SET &I=2
-INCLUDE FUNCTION_AA

and then

-* FUNCTION_AA

-IF &ASA EQ 'Y' THEN GOTO label&I.EVAL;
... code...code...
-label&I.EVAL


But WF do not see where is label1 or label2 when it comes to GOTO sentence.

Any trick to solve this?

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


Wf7704/WF8,Win64/32
November 05, 2013, 11:55 AM
Francis Mariani
Maybe this is a solution:

-DEFAULT &I = '1';

-GOTO LABEL&I.EVAL

-LABEL1
-TYPE LABEL1
-GOTO LABEL_END

-LABEL2
-TYPE LABEL2
-GOTO LABEL_END

-LABEL3
-TYPE LABEL3
-GOTO LABEL_END

-LABEL_END



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
November 05, 2013, 12:39 PM
Piter
DO you mean (or I have found a trick Smiler ) that in my procedure (repeatable text ) if I know number of use then I should mention all labels like that


-IF &ASA EQ 'Y' THEN GOTO label&I.EVAL;
... code...code...
-label1
-label2
-label3
-label4
...


interesting and I am thinking that may be usable


Wf7704/WF8,Win64/32
November 05, 2013, 12:51 PM
Francis Mariani
Yes, add all the possible labels because I don't think you can have a parameterised label.


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
November 06, 2013, 05:24 AM
Danny-SRL
Piter,
As far as I know, when you -INCLUDE as fex all labels are at first treated as local, meaning that WF will search the -INCLUDEd fex for labels. If a label is not found, then it will look in the calling fex.
See the following example.
The calling fex:
  
-SET &ECHO=ALL;
-* File piter01.fex
TABLE FILE CAR
PRINT COUNTRY
ON TABLE HOLD AS PITER FORMAT ALPHA
END
-RUN
-SET &R=&LINES;
-REPEAT #GETCOUNTRY FOR &I FROM 1 TO &R;
-READFILE PITER
-INCLUDE PITER00
-#GETCOUNTRY
-TYPE DONE


The -INCLUDEd fex:
  
-* File piter0.fex
-GOTO #PITER0
-#PITER00
-TYPE Back &I
-GOTO #OUT
-#PITER0
-TYPE I=&I COUNTRY=&COUNTRY
-GOTO #PITER00
-#OUT

Try it!


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

November 06, 2013, 06:51 AM
Piter
thanks, Daniel. Your case is clear. I was asking about dynamic labels and seems it is also clear - like Francis wrote - WF do not do "precompile" and will not understand 'future' dynamic labels


Wf7704/WF8,Win64/32