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     Loop --reading a value

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Loop --reading a value
 Login/Join
 
<delvegas>
posted
Hi guys

Is there a way to read data from a single column

like I have a Table X1 which contains 4 rows of data like
Field1
A
B
C
D
under a sigle field1.

what i need is to read the data from each row at a time. and store it in &variable and type.

Field Data is dynamic. ie:- it can contain 10 or 50 Rows of data.

Thanks
 
Report This Post
Platinum Member
posted Hide Post
Something like this:

DEFINE FILE X1
X/A1 WITH FIELD1 = 'X';
END
TABLE FILE X1
PRINT FIELD1 X
ON TABLE SAVE
END
-RUN

-REPEAT READLOOP FOR &NDX FROM 1 TO 1000
-READ SAVE &FIELD&NDX.EVAL.A20.

-IF &IORETURN NE 0 THEN GOTO EOF;
-TYPE &FIELD&NDX.EVAL
-GOTO READLOOP

-EOF
-SET &DUMMY = 1000;

-READLOOP
-? &


Notes:

I assumed a format of A20 for FIELD1.

The -RUN after the TABLE FILE is essential.

If you don't print X, then the records you create will be of variable length (unless the text in FIELD1 is always the same number of characters, or numbers). If the first record in SAVE is, for example only 15 characters wide, and you read it into a variable 20 characters wide (.A20.), FOCUS will grab the first 5 characters of the of the second record. The second time you encounter -READ, FOCUS will read the third record, not the second record. The X at the end (in the 21st position) assures that this will not happen.

The 1000 in the REPEAT loop is arbitrary. Pick a number that is greater than the number of records you will EVER print from X1.

It is &IORETURN that tells you when you are done reading the file. YOu could simply jump to some point outside the REPEAT loop, but I have quaint preference for completing the loop.

The -GOTO READLOOP takes you to the end of the loop. When FOCUS encoutners -READLOOP, it returns back to the top of the loop.

The -? & at the end will display your variables and their values.
 
Posts: 135 | Location: Portland, OR | Registered: March 23, 2005Report This Post
<JG>
posted
Change
-REPEAT READLOOP FOR &NDX FROM 1 TO 1000
to
-SET &LOOP=&RECORDS;
-REPEAT READLOOP FOR &NDX FROM 1 TO &LOOP

This will perform the loop the exact number of times and you can then delete the following lines of code
-IF &IORETURN NE 0 THEN GOTO EOF;
-GOTO READLOOP
-EOF
-SET &DUMMY = 1000;


By the way -SET &DUMMY = 1000; should be -SET &NDX = 1000;

Also to force a fixed length file all you need to do is filedef the file as follows before the request
FILEDEF SAVE DISK SAVE.FTM (LRECL 20 RECFM F
-RUN

This will allow you to remove the define and field x from the request
 
Report This Post
Master
posted Hide Post
delvegas,

What are you trying to do with the variable(s)? WebFOCUS has a lot of powerful features that can be used to help you complete your task and there may be a better way to accomplish the task you are trying to complete. Cool
 
Posts: 865 | Registered: May 24, 2004Report 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     Loop --reading a value

Copyright © 1996-2020 Information Builders