Focal Point
[solved]simple question on replacing GOTO name

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

May 24, 2017, 10:55 AM
WFDevConsultant
[solved]simple question on replacing GOTO name
I am trying to give some dynamic name for my GOTO statement but unfortunately it is not working. I might be doing something wrong OR that is not possible. How can I achieve that?

sample code:

-SET &CNT=1;

-SET &TESTVAR='TEST';

-IF &CNT EQ 1 THEN GOTO &TESTVAR.EVALLOOP1
-ELSE GOTO &TESTVAR.EVALLOOP2;

-&TESTVAR.EVALLOOP1
-TYPE LOOP1 VALUE
-&TESTVAR.EVALLOOP2
-EXIT

when I run the above code, it throws the error says "TESTLOOP1 is missing".

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


8.2.06
Windows, All Formats
May 24, 2017, 11:13 AM
GamP
It is easier than you might think...
-SET &CNT=2;

-SET &TESTVAR='TEST';

-GOTO &TESTVAR&CNT

-TEST1
-TYPE LOOP1 VALUE
-EXIT
-TEST2
-TYPE THIS IS LOOP 2
-EXIT



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
May 24, 2017, 11:24 AM
WFDevConsultant
I cannot do that because I will be using the same code on bottom of my report. If I do like this then my report is getting in to infinite loop.


8.2.06
Windows, All Formats
May 24, 2017, 11:43 AM
MartinY
A tag (step name) cannot be dynamic it must exist before evaluation, the GOTO can be dynamic as shown by GamP.
Each tag must be unique and you need a condition that will get you out of the loop.

It looks like we're missing some information to answer you properly.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
May 24, 2017, 11:52 AM
j.gross
You need to understand the rules:

SO:
If you can wrap one or both of the sections containing a GOTO and the labels it references in a separate fex file, -INCLUDEd in the main fex, there will be no conflict. That will allow you to use the same "stub" for all the labels, and simplify the form of the GOTO to "GOTO STUB&CNT.EVAL".

If you are inserting the same logic into a succession of TABLE requests, you can skirt the issue by wrapping each TABLE request in a separate fex invoked via -INCLUDE.
May 24, 2017, 01:59 PM
WFDevConsultant
Thanks all for the valuable inputs. It helps me understand the rules of GOTO (Thanks J.gross).

I ended up using the & variable after the static value as J.gross mentioned.


8.2.06
Windows, All Formats