Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read from TOP again after reaching END-OF-FILE

Status
Not open for further replies.

objectcodeonly

Programmer
Mar 29, 2003
2
US

Hi all,

Need help please >>

I want to get to the TOP-OF-FILE after reaching the END-OF-FILE (I am talking of the same file). Do I still use :

READ File1
AT END MOVE 'Y' to SWITCH

What is the BEST Technique to get the read to go to to the TOP of file again (Sort of LOOP)

Please answer soooon...thanks a LOT!!
 
hi,

close that file after the end-of-file, open it again and read.

Regards,

Crox
 
Yes a file-close-open routine is what works best for RANDOM ACCESS. If you have DYNAMIC ACCESS a START statement might let you reposition the pointer and then perform READ NEXT.

If you do not like my post feel free to point out your opinion or my errors.
 
For a sequentail files,whenever we isssue a READ statement after we open the file,the pointer poistions itself to the next record.Simply changing the status of the EOF will have no effect on the pointer.So what we can do is, we can [red]put the function of opening the file in a seperate paragraph and we can call that paragraph everytime the EOF (End-of-file)becomes true.Remeber to close the file before opening the file again!!!!![/red]
If any other queries please feel free to fwd it to me
Regds
Itron
 
I've written COBOL for many years and I can't think
of any case why you would want to start over at the top.
I suspect one of 2 things:---- you are looking for a record
and you are reading through the file, wanting to close
the file, open it again and look for another record.
You should use the START statement. It starts
you near the record your are looking for.

The only other case I can think of is that you have 2 files
that you are matching to a master file sequentially
and you want to process transaction file 1 against
master file 1 sequentially and then then process transaction file 2 against the master file as well.
I guess you could close the master file and re-open it.
I would use another technique.

Bottom line --- be sure you aren't reading
all the records on the master file over and over.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top