Jump to content

Okay - you know what I mean I had a case last night where s...


Toby Mills

Recommended Posts

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...