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] SET Variable Inside REPEAT - Not Working Properly

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] SET Variable Inside REPEAT - Not Working Properly
 Login/Join
 
Guru
posted
Hi,

I am trying to execute the following code.

&SEL_A0 is the count of &SEL_A'N' s present.

-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A&COUNTER;
-END_REP

-TYPE &TOKENVAL

My Expected output is #10#11#97#99


But It is expecting a value for &SEL_A .

&SEL_A&COUNTER is eveluvated togather to form &SEL_A1, &SEL_A2, &SEL_A3 etc.

Is there any simple way to do this ?

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


Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Expert
posted Hide Post
quote:
-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A&COUNTER.EVAL;
-END_REP

That should get you further forward.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Or, as the syntax for indexed variables says:

-SET &name.&index[.&index...] = expression;

The '.' is the missing bit.
[Tony. you know I avoid .EVAL like the plague Wink]


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Expert
posted Hide Post
quote:
you know I avoid .EVAL like the plague ]

... and you have been plague free of recent years Wink

Except that neither of our responses actually take it forward Frowner too early?

T

This message has been edited. Last edited by: Tony A,



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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
  
-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER;
-END_REP

-TYPE &TOKENVAL




Hi Tony / Alan,

Thanks for your replies.

I tried both the suggestions. But, still It is expecting a value for &SEL_A .

What I need is to form the &VAR's name dynamically along with the counter...

Eg. &SEL_A1, &SEL_A2 like that...


But what I get is



Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Expert
posted Hide Post
Firstly, you need your -REPEAT terminated by a semicolon (doc'd syntax) and then -

-SET &ECHO=ALL;
-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &Cnt FROM 1 TO &SEL_A0.EVAL;
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A&Cnt.EVAL;
-END_REP

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER;
-END_REP

-TYPE &TOKENVAL


works perfectly for me. Using .EVAL still prompts.

-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';
-REPEAT END_REP FOR COUNTER FROM 1 TO 4
-SET &TOKENVAL = || '#' || 10;
-REPEAT END_REP FOR COUNTER FROM 1 TO 4
-SET &TOKENVAL = #10 || '#' || 11;
-REPEAT END_REP FOR COUNTER FROM 1 TO 4
-SET &TOKENVAL = #10#11 || '#' || 97;
-REPEAT END_REP FOR COUNTER FROM 1 TO 4
-SET &TOKENVAL = #10#11#97 || '#' || 99;
-REPEAT END_REP FOR COUNTER FROM 1 TO 4
-END_REP
-TYPE #10#11#97#99
#10#11#97#99


If the index variable doesn't work, i.e.
-SET &ECHO=ALL;
-SET &SEL_A0 = 4;
-*SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER;
-END_REP

-TYPE &TOKENVAL

results in:
-SET &SEL_A0 = 4;
 -*SET &SEL_A1 = 10;
 -SET &SEL_A2 = 11;
 -SET &SEL_A3 = 97;
 -SET &SEL_A4 = 99;
 -SET &TOKENVAL = '';
 -REPEAT END_REP FOR  COUNTER FROM 1 TO 4
 0 ERROR AT OR NEAR LINE     10  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC295) A VALUE IS MISSING FOR: &SEL_A1



This is because parameter prompting is a pre-parser and does not see &SEL_A1. This is not seen until the process actually runs. For neither does parameter prompting come in to play.

(pressed POST too early…)

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
Interesting.
-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';

-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER.EVAL;
-END_REP

-TYPE &TOKENVAL
causes parameter prompting.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
quote:
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER.EVAL;
-END_REP
...causes parameter prompting


Why? Simple:

After the EVALuation, you are left (on the first round) with:

-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.1;

Since "1" is not a reference to a variable, the syntax for indexing is not satisfied, and the "." just indicates catenation, to be performed after &SEL_A is evaluated.

Since &SEL_A is undefined, you get prompted.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Guru
posted Hide Post
Hi All,

Thanks for the Reply.

As said, .EVAL played it... It worked.

But Still,

Alan,

It is bit more Interesting that, In 7.6.9 It worked perfect, and in 7.1.4 This is is making a user prompt. Still... Donno Y.. ? Wink


Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Platinum Member
posted Hide Post
If you had used a -RUN after your -SETs your original would have worked fine (apart from the missing '.') because it would have forced the evaluation of the SETs before starting the REPEAT loop. Much simpler than .EVAL

-SET &SEL_A0 = 4;
-SET &SEL_A1 = 10;
-SET &SEL_A2 = 11;
-SET &SEL_A3 = 97;
-SET &SEL_A4 = 99;
-SET &TOKENVAL = '';
-RUN
-REPEAT END_REP FOR &COUNTER FROM 1 TO &SEL_A0
-SET &TOKENVAL = &TOKENVAL || '#' || &SEL_A.&COUNTER;
-END_REP

-TYPE &TOKENVAL
 
Posts: 140 | Location: Adelaide South Australia | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
-RUN
adds nothing for variables that are already set by -SET.


I suggest you play by the book.

Indexing, using the construct "&base.&index", is documented.

But "&base&index.EVAL", or even "&base.&index.EVAL", is not documented as a means to reference "indexed" variables, and its semantic interpretation may vary with the release.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Guru
posted Hide Post
hi Opaltosh/J.Gross,

It works fine in 769 with and without RUN.

But in 7.1.4 still doing a user prompt.


Thanks,

Ramkumar.
WebFOCUS/Tableau
Webfocus 8 / 7.7.02
Unix, Windows
HTML/PDF/EXCEL/AHTML/XML/HTML5
 
Posts: 394 | Location: Chennai | Registered: December 02, 2009Report This Post
Virtuoso
posted Hide Post
I take it it is still asking for the &SEL_A variable?
If so, since you're not really using that variable, try to do a -SET &SEL_A = ''; in the very top of your fex. That way the var is known and no prompting will take place. And then hope the rest of the fex still works ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report 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] SET Variable Inside REPEAT - Not Working Properly

Copyright © 1996-2020 Information Builders