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     Creating a Variable for LOOP counting from a Table File command

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Creating a Variable for LOOP counting from a Table File command
 Login/Join
 
<AUSSIE_SEAGULL>
posted
Does anyone have sample code that can create a variable to be used to set the number of times a LOOP will execute based on the result of a count of records, eg:

DEFINE FILE TABLE1
COUNT/I3 = 1;
END

TABLE FILE TABLE1
SUM COUNT
ON TABLE HOLD AS XYZ
END
-RUN

and use the value of the count to set the variable that controls the number of times a sunsequent LOOP will run further down the code?

All suggestions welcome !
 
Report This Post
<Pietro De Santis>
posted
DEFINE FILE CAR
COUNT/I3 = 1;
END

TABLE FILE CAR
SUM COUNT
CAR NOPRINT
ON TABLE HOLD AS XYZ FORMAT ALPHA
END
-RUN

-READ XYZ &ZCOUNT.I3.
-TYPE &ZCOUNT

-REPEAT END_LOOP1 FOR &I FROM 1 TO &ZCOUNT

-TYPE COUNT IS &I

-END_LOOP1
 
Report This Post
Guru
posted Hide Post
&LINES or &RECORDS could work for you. They are variables that are created by FOCUS after every table call which contains the number of row in the data set (&LINES) and how many lines was read from the database (&RECORDS).
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Expert
posted Hide Post
g'day, i use &LINES.
TABLE FILE CAR
BY MODEL
ON TABLE HOLD
END
-RUN
-SET &NUMCARS = &LINES ;
-REPEAT MYENDLOOP &NUMCARS TIMES
TABLE FILE somethingelse
...do stuff
END
-RUN
-MYENDLOOP
-**** or use explicit kounter
-SET &KOUNTER = 0;
-MYTOPLOOP
-SET &KOUNTER = &KOUNTER + 1;
TABLE FILE something
..do stuff
END
-RUN
-IF &KOUNTER LT &NUMCARS GOTO MYTOPLOOP;
-*you're allright now
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
<AUSSIE_SEAGULL>
posted
Thanks all for your suggestions, I have only checked the posts now (been up to the eyeballs in work!) I'll leave the subject open and let you know how I go .

Thanks again ....
 
Report This Post
<AUSSIE_SEAGULL>
posted
Susannah your suggestion has worked a treat, thank you very much, I have solved not just the coding issue but provided a tool to really boost productivity in a few key business areas I deal with.
 
Report This Post
Expert
posted Hide Post
great to know. Congratulations.
Take a look at Pietro's suggestion...its slightly different, and also very important technique that will give you alot more ideas...You can not only count how many somethings there are...you can actually make a list of them, read them 1 at a time, and loop with an actual value of variable, not just a loop kounter.
Be sure and come to Tech Summit in May in LasVegas and pick up lots more great ideas from everyone!
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report 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     Creating a Variable for LOOP counting from a Table File command

Copyright © 1996-2020 Information Builders