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] Dynamic Define field.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Dynamic Define field.
 Login/Join
 
Gold member
posted
Hi all,
I am trying to implement a programming solution where i have to create a define field dynamically from a list of amper variables. The number of amper variable may vary and the define definition should automatically take the new added amper variable into it's definition. The structure of define field is like this.

ABC/A20=IF CODE IN (&GRP1) THEN GROUP1 ELSE IF CODE IN (&GRP2) THEN GROUP2 ELSE IF CODE IN (&GRP3) THEN GROUP3 ......... ELSE CODE;

I was trying to do this with a loop but not able to make it in single line. Can somebody please advise.

Thanks

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


7.6.11
Linux
Excel, HTML, PDF

 
Posts: 69 | Registered: February 15, 2008Report This Post
Virtuoso
posted Hide Post
Chirag,

2 assumptions:
1. You have a variable, &GRP0, which contains the number of variables
2. This number is not greater than 16 (unless the number of nested IFs has increased...)

With these assumptions in mind, here is a solution:
  
-* File Chirag01.fex
...
ABC/A20=
-REPEAT #GRPS FOR &I FROM 1 TO &GRP0;
IF CODE IN (&GRP.&I) THEN GROUP&I ELSE
-#GRPS
CODE;
...


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Expert
posted Hide Post
quote:
but not able to make it in single line

Why do you want it on a single line?

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
Gold member
posted Hide Post
No, I don't want to make it to single line. I thought define field accept definition given in single line only. As i was getting error with my initial try with repeat loop. But Daniel solution worked for me. But unfortunately in my case the number is going to be more than 16.

Thanks


7.6.11
Linux
Excel, HTML, PDF

 
Posts: 69 | Registered: February 15, 2008Report This Post
Virtuoso
posted Hide Post
One alternative is to use a loop to create a DEFINE for each group pair and check the value of the previous DEFINE before proceeding with the current one. The last DEFINE should contain the final value. I have not tested this code so it may require some tweaking - particularly the number of dots before EXISTS; some .EVALs might also be needed.

 TEST0/A20 = 'XXXXXXXX';
-REPEAT ENDREPEAT1 FOR &I FROM 1 TO 100 ;
-SET &PI = &I - 1 ;
-IF &GRP.&I..EXISTS EQ 0 GOTO QUITREPEAT1 ;
 TEST&I/A20 = IF TEST&PI NE 'XXXXXXXX' THEN TEST&PI ELSE IF CODE IN (&GRP.&I) THEN GROUP&I ELSE 'XXXXXXXX';
-ENDREPEAT1
-QUITREPEAT1
-*
ABC/A20 = TEST&PI ;

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
quote:

But Daniel solution worked for me. But unfortunately in my case the number is going to be more than 16.


In that case, here is a general solution:
  
...
ABC0/A20=CODE;
-SET &OUTGRP=&GRP0 / 15;
-REPEAT #OUTGRP FOR &G FROM 1 TO &OUTGRP;
-SET &F=(&G - 1) * 15 + 1;
-SET &T=&F + 15 - 1;
-SET &L=&G - 1;
ABC&G/A20=
-REPEAT #GRPS FOR &I FROM &F TO &T;
IF CODE IN (&GRP.&I) THEN GROUP&I ELSE
-#GRPS
ABC&L;
-#OUTGRP
-SET &LGRP=&OUTGRP*15;
-IF &GRP0 EQ &LGRP GOTO #DONE;
-SET &LOUTGRP=&OUTGRP;
-SET &OUTGRP=&OUTGRP+1;
-SET &LLGRP=&LGRP+1;
ABC&OUTGRP/A20=
-REPEAT #LGRP FOR &I FROM &LLGRP TO &GRP0;
IF CODE IN (&GRP.&I) THEN GROUP&I ELSE
-#LGRP
ABC&LOUTGRP;
-#DONE
ABC/A20=ABC&OUTGRP;
...

Some good ol'fashioned programming...
Cool


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

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Gold member
posted Hide Post
Thanks Dan & Danny for the wonderful technique.


7.6.11
Linux
Excel, HTML, PDF

 
Posts: 69 | Registered: February 15, 2008Report 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] Dynamic Define field.

Copyright © 1996-2020 Information Builders