Follow up on COBOL Tip 11.

Previous topicNext topic

Topic Author
Mahesh Ayyar
New Member
Posts: 6
Joined: Thu Jan 16, 2014 4:48 pm

Follow up on COBOL Tip 11.

Post by Mahesh Ayyar » Tue Jan 21, 2014 5:59 pm

Pandora-Box wrote:11.When ever we do processing reading a file better to have an approach like this


Templace

Code: Select all

         Open file
         Read file
         process until EOF
                     "MAIN PROCESSING"
                      Read file
         Close file   
Hi,

May be I did not get it but - why do you say so Pandora?
Last edited by Anuj Dhawan on Tue Jan 21, 2014 6:08 pm, edited 1 time in total.
Reason: Changed the subject to: Follow up on COBOL Tip 11.




zprogrammer
Global Moderator
Global Moderator
Posts: 605
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Zodiac: Libra

Re: COBOL Tips doubt

Post by zprogrammer » Tue Jan 21, 2014 6:07 pm

Hi,

Mahesh I believe it more structured way of programming


zprogrammer


Topic Author
Mahesh Ayyar
New Member
Posts: 6
Joined: Thu Jan 16, 2014 4:48 pm

Re: Follow up on COBOL Tip 11.

Post by Mahesh Ayyar » Wed Aug 20, 2014 2:14 pm

This been a while but trying to understand it, you mean to use proper indentation?




William Collins
Global Moderator
Global Moderator
Posts: 499
Joined: Sun Aug 25, 2013 7:24 pm

Re: Follow up on COBOL Tip 11.

Post by William Collins » Wed Aug 20, 2014 3:53 pm

No, it is the use of what is sometimes called a "Priming Read". If you notice, there are two Reads in the example. One immediately before the loop, and one the last thing in the loop. The code within the loop will only be processed when a record is present. With a Read at the top of the loop, you end up with squirming about to avoid processing a record when you have reached end-of-file.



Previous topicNext topic

Return to “Follow up on Tips”