March 21, 2007, 12:55 PM
Mark1&IORETURN
Can anybody tell me how this variable works? I have been using it in one of my loops that reads a text file. I use it to loop until the end of my text file.
My guess is that when I set it equal to zero before the start of my loop then it stays that way for every record until there are no records left.
Windows version 768
March 21, 2007, 01:20 PM
Francis MarianiYou don't need to set the variable:
FILEDEF DMDCD DISK IBISAMP/DMDCD.FTM
-RUN
-SET &NB_LINES = 0;
-READ DMDCD &STID.A2 X1 &ST_NAME.A27.
-REPEAT ENDREP1 WHILE &IORETURN EQ 0;
-SET &NB_LINES = &NB_LINES + 1;
-TYPE &STID &ST_NAME
-READ DMDCD &STID.A2 X1 &ST_NAME.A27.
-ENDREP1
-TYPE &NB_LINES
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
March 21, 2007, 01:25 PM
Mark1If I don't set it, I get this error:
(FOC295) A VALUE IS MISSING FOR: &IORETURN
Windows version 768
March 21, 2007, 01:35 PM
Francis MarianiThe example I provided is a working one. I don't declare &IORETURN but it works. Probably because of the first READ, outside the loop.
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
March 21, 2007, 01:42 PM
Alan BMark
Francis is correct, and you should not need to SET &IORETURN, it is a system variable.
Do you want to post your code so that we can see what you are doing.
Alan.
WF 7.705/8.007
March 21, 2007, 01:50 PM
Tony AMark,
The &IORETURN variable is an internal one and is primed in Francis' example by performing a READ operation before it is checked.
It is an old methology that is still stands today although from most posts it doesn;t seem to be put into practice. It is also the most logical way to process a file, in that you "read ahead", check the IO status, process the input, read the next line and then start again.
Read through Francis' example carefully, understand it and compare it to your process.
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 | |
March 21, 2007, 01:51 PM
Mark1The funny thing is that I modified my code when I looked at Francis' so that the -READ came before the -REPEAT statement (and took out the line that sets &IORETURN = 0) and it seemed to like that except I got an error saying that I didn't have enough virtual memory. Here is my original code:
FILEDEF SSN DISK "\\HORSEISLAND\NETSHARE\MEDICAL\OOQ\CLINICAL INFO MGMT\CMPROJECTS\OCCUPATIONAL HEALTH\WORKERSCOMP\SSN.TXT" (LRECL 9
-RUN
-SET &SSN=' ';
-SET &IORETURN = 0 ;
-REPEAT MYLOOP WHILE &IORETURN EQ 0 ;
-READ SSN NOCLOSE &SSN.A9.
TABLE FILE T2PERSON
...[a bunch of code]...
FILEDEF OUTPUT DISK \\HORSEISLAND\NETSHARE\MEDICAL\OOQ\SOLUTIONSWORLD\WORLDS\MARK\WORK\FEB07\OUTPUT.TXT (APPEND
TABLE FILE MYOUT
SUM BALANCE
BY PERSON_FIRST_NAME
BY PERSON_LAST_NAME
ON TABLE HOLD AS OUTPUT FORMAT COM
END
-MYLOOP
-EXIT
Windows version 768
March 21, 2007, 02:03 PM
Alan BMark
Another way to work with &IORETURN:
FILEDEF SSN DISK "\\HORSEISLAND\NETSHARE\MEDICAL\OOQ\CLINICAL INFO MGMT\CMPROJECTS\OCCUPATIONAL HEALTH\WORKERSCOMP\SSN.TXT" (LRECL 9
FILEDEF OUTPUT DISK \\HORSEISLAND\NETSHARE\MEDICAL\OOQ\SOLUTIONSWORLD\WORLDS\MARK\WORK\FEB07\OUTPUT.TXT (APPEND
-RUN
-SET &SSN=' ';
-REPEAT MYLOOP 99999 TIMES
-READ SSN NOCLOSE &SSN.A9.
-IF &IORETURN NE 0 GOTO OUTLOOP;
TABLE FILE T2PERSON
...[a bunch of code]...
TABLE FILE MYOUT
SUM BALANCE
BY PERSON_FIRST_NAME
BY PERSON_LAST_NAME
ON TABLE HOLD AS OUTPUT FORMAT COM
END
-RUN
-MYLOOP
-OUTLOOP
-EXIT
Also you shouldn't need to keep the OUTPUT FILEDEF in the loop, and a RUN in between so that FOCSTACK doesn't get too big. So &IORETURN doesn't need priming as Tony says, because the READ does the priming for you.
Alan.
WF 7.705/8.007
March 21, 2007, 03:45 PM
Mark1Cool!!! Thanks to all who responded. This is great!
Windows version 768