Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [solved]simple question on replacing GOTO name
Go
New
Search
Notify
Tools
Reply
  
[solved]simple question on replacing GOTO name
 Login/Join
 
Platinum Member
posted
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
 
Posts: 171 | Registered: December 27, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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 7 - IE11.
in Focus since 1988
 
Posts: 1960 | Location: Netherlands | Registered: September 25, 2007Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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
 
Posts: 171 | Registered: December 27, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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
 
Posts: 2284 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
You need to understand the rules:

  • The GOTO reference to a label can be dynamic (use a &var and .EVAL)

  • The line declaring the referenced label must appear in the same fex file as the GOTO, and must be static (i.e., no &'s).

  • All labels appearing in a single fex file must be unique.

  • A GOTO statement can only reference labels declared in the same fex file.

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.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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
 
Posts: 171 | Registered: December 27, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [solved]simple question on replacing GOTO name

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.