Focal Point
-READ how to determine how many lines or records are in a file?
November 21, 2006, 01:10 PM
Tomsweb-READ how to determine how many lines or records are in a file?
Is there a command one can use to determine how many lines or records are in a file along with issuing
a -READ to read the data?
Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
November 21, 2006, 01:50 PM
Jim_at_LMNot sure if you mean:
-LOOP
-READ fn &VAR.xx., . . .
-SET &RECCOUNT = &RECCOUNT + 1;
-IF &IORETURN NE 0 GOTO END_LOOP ;
-GOTO LOOP ;
-END_LOOP
WebFOCUS 7.6.11, WINDOWS, HTML, PDF, EXCEL
November 21, 2006, 02:20 PM
Francis MarianiOr this perhaps:
-SET &FILE1_COUNT = 0;
-READ FILE1 NOCLOSE &COUNTRY.A10.
-REPEAT END_LOOP1 WHILE &IORETURN EQ 0;
-SET &FILE1_COUNT = &FILE1_COUNT + 1;
-TYPE COUNTRY: &COUNTRY
TABLE FILE CAR
PRINT MODEL
WHERE COUNTRY EQ '&COUNTRY'
ON TABLE HOLD AS HOLD02 FORMAT ALPHA
END
-RUN
-READ FILE1 NOCLOSE &COUNTRY.A10.
-END_LOOP1
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 21, 2006, 03:31 PM
TomswebJim,
I think you meant this:
-SET &RECCOUNT = 1;
-LOOP
-*
-READ TSPF &SCHDTE.A8. &EVTDT.A8. &EVTTM.A8. &TRNTYP.A1.
-*
-TYPE REC#: &RECCOUNT &SCHDTE &EVTDT &EVTTM &TRNTYP
-*
-IF &IORETURN NE 0 GOTO END_LOOP;
-SET &RECCOUNT = &RECCOUNT + 1;
-GOTO LOOP;
-END_LOOP
-TYPE
-TYPE RECORD TOTAL = &RECCOUNT
-EXIT
THANKS!
Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
November 21, 2006, 03:38 PM
Jim_at_LMYes, you're right, I missed that (in a hurry over here). Thanks for updating that!
WebFOCUS 7.6.11, WINDOWS, HTML, PDF, EXCEL
November 22, 2006, 05:27 AM
Tony ATom,
If the file is relatively small then there can be a valid time when you might want to do this, such as if you are actually going to do something with the data that you are reading in (e.g. assigning variable values) ...
but, if you have an MFD for it, then why not just issue a table request against it and then use &LINES?
If you haven't an MFD, then just create one on the fly and filedef your source to it, finally issue a table request and then use &LINES.
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 | |
November 22, 2006, 05:33 AM
Tony AIf you have to go the route of issuing -READS then I would suggest keeping -GOTOs far and few between.
If you use a structured approach then you would read the file and then perform a loop while a read is successful - termed "read ahead".
-SET &RECCOUNT = 0;
-*
-READ TSPF &SCHDTE.A8. &EVTDT.A8. &EVTTM.A8. &TRNTYP.A1.
-*
-REPEAT END_LOOP WHILE &IORETURN EQ 0;
-*
-SET &RECCOUNT = &RECCOUNT + 1;
-TYPE REC#: &RECCOUNT &SCHDTE &EVTDT &EVTTM &TRNTYP
-*
-READ TSPF &SCHDTE.A8. &EVTDT.A8. &EVTTM.A8. &TRNTYP.A1.
-*
-END_LOOP
-TYPE
-TYPE RECORD TOTAL = &RECCOUNT
-EXIT
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 | |