ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Need to loop through a file twice in CL (2 RCVF loops) - how?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to loop through a file twice in CL (2 RCVF loops) - how?

    I have one file that I want loop through twice in a CL, but the 2nd time through system finds the file at EOF. How can I accomplish this? (tried to CLOF btw loops but that didn't work)

  • #2
    Found a logical that I could use on a second DCLF and on the second RCVF loop. But still curious how I could've worked around the problem had I not had the logical....

    Comment


    • #3
      You've tried using CLOSE?

      The Close Database File (CLOSE) command can be used to close a database file that is implicitly opened by the Receive File (RCVF) command.

      Comment


      • #4
        Thank you!! I have never heard of, or seen the command CLOSE!

        Comment


        • #5
          In the old days, CL would automatically open a file the first time you call RCVF, and automatically close it when you hit EOF (or the program ended). However, people kept asking the same question you've asked "how do I read the file a second time", and there wasn't a great answer. One way is to end/restart the program. Another way is to do a shared open with OPNDBF, code your program so you never hit EOF, and then use POSDBF to move back to the start -- but this was somewhat complex, and people didn't understand the difference between the shared open with OPNDBF/POSDBF/CLOF and the CL program open/closing the file, so they'd hit roadblocks and get frustrated.

          Finally, after enough complaining IBM added the CLOSE command ;-)

          Comment

          Working...
          X