Toby Mills Posted March 15, 2022 Posted March 15, 2022 Okay - you know what I mean I had a case last night where some code Ive inherited uses -READ filename NOCLOSE to loop through a flat file full of fieldnames 3 times. What the code wants to do is iterate through a variable number of fieldnames (the names of the fields vary by the report being run). It then wants to do a TABLE Anyway, the goal appears to be to do a DEFINE, then a TABLE , then another TABLE and keep reusing this dynamic list of fields that is stored in a flat file. Sort of like this: -* generate a list of fields for this report TABLE FILE MYREPORTFIELDS PRINT FIELDNAME ON TABLE SAVE AS MYFLDLIST END -RUN DEFINE FILE WHEE -READ MYFLDLIST NOCLOSE &FLDNAME.80 &FIELDNAME=FOC_NONE; -loop as many times as this report has for parameters. END TABLE FILE WHEE PRINT -READ MYFLDLIST NOCLOSE &FLDNAME.80 &FIELDNAME -loop as many times as this report has for parameters. ON TABLE HOLD AS HOLD1 END -RUN TABLE FILE WHEE PRINT -READ MYFLDLIST NOCLOSE &FLDNAME.80 &FIELDNAME -loop as many times as this report has for parameters. ON TABLE HOLD AS HOLD2 END In 8105M, the -READ NOCLOSE actually DID close the file between these runs for some reason. Not sure why even with the -RUNs. The -NOCLOSE should have overridden the -RUNs attempt to close all open files. In 8207, I had to make sure to pair these -NOCLOSEs with a corresponding -CLOSE to iterate through the save file correctly. This actually seems to be the proper way to have done this anyway. So youd add a -CLOSE MYFLDLIST After each loop of -READs to make sure you start at the top of the file again on your next -READ.
Charles Morris 2 Posted March 16, 2022 Posted March 16, 2022 hey, Toby! Yes, technically if you want to restart at the top of the file you would need a -CLOSE - the -READ NOCLOSE was more built to do within a loop to just keep reading and then CLOSE at the end of the process but with all the other activities in your example I would think it gets lost
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now