Focal Point
[CLOSED] Repeat Loop

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3487074476

January 28, 2015, 10:26 AM
Enigma006
[CLOSED] Repeat Loop
Hello

Below is a code I am working on and this is a base for a different project of mine.
I got it to work but only 1 value (ENGLAND) is being repeated in all 5 sets of data.
TABLE FILE CAR
PRINT
	DST.COUNTRY
ON TABLE HOLD AS C2
END
-RUN
-SET &LOOPCNT = &LINES;
-READ C2 &COUNTRY.A10.
-RUN


Thanks

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


8.1.05
HTML,PDF,EXL2K, Active, All
January 28, 2015, 10:34 AM
Tom Flynn
Just like the manual states, use NOCLOSE to continue reading a file...

-READ C1 NOCLOSE


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
January 28, 2015, 10:55 AM
j.gross
Or convert to -READFILE, which leaves the file open across -RUNs


- Jack Gross
WF through 8.1.05
January 28, 2015, 02:17 PM
MartinY
Or remove the -RUN after the -READ

TABLE FILE CAR
PRINT DST.COUNTRY
ON TABLE HOLD AS C2
END
-RUN
-SET &LOOPCNT = &LINES;
-SET &I = 1;
-NXTREAD
-READ C2 &COUNTRY.&I.A10.
-*-RUN
-TYPE &COUNTRY.&I
-SET &I = &I + 1;
-IF &I LT &LOOPCNT THEN GOTO NXTREAD;


And have a loop...


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
January 28, 2015, 03:30 PM
Waz
I guess this is a code snippet, as I do't see any loop.

You can also use -REPEAT for the loop.

e.g.
TABLE FILE CAR
PRINT DST.COUNTRY
ON TABLE HOLD AS C2
END
-RUN
-SET &LOOPCNT = &LINES;
-REPEAT NXTREAD FOR &I FROM 1 TO &LOOPCNT ;
-READ C2 &COUNTRY.&I.A10.
-TYPE &COUNTRY.&I
-NXTREAD



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!