Follow up on COBOL Tip 11.

Post Reply
Mahesh Ayyar
Registered Member
Posts: 13
Joined: Thu Jan 16, 2014 4:48 pm

Follow up on COBOL Tip 11.

Post by Mahesh Ayyar »

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: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: COBOL Tips doubt

Post by zprogrammer »

Hi,

Mahesh I believe it more structured way of programming
zprogrammer
Mahesh Ayyar
Registered Member
Posts: 13
Joined: Thu Jan 16, 2014 4:48 pm

Re: Follow up on COBOL Tip 11.

Post by Mahesh Ayyar »

This been a while but trying to understand it, you mean to use proper indentation?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Follow up on COBOL Tip 11.

Post by William Collins »

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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Follow up on Tips”