WRITE and WRITE FROM in COBOL?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
User avatar
Kishor Bag
Registered Member
Posts: 10
Joined: Thu Jan 16, 2014 4:46 pm

WRITE and WRITE FROM in COBOL?

Post by Kishor Bag »

One can get the last record if we used "WRITE FROM" from some WS variable. But when you use only WRITE, the data is no longer available to the program because the pointer to the i/o buffer has been moved. If a programmer refers to the record-area after the WRITE (not WRITE FROM), the result is unpredictable - is this understading correct about WRITE and WRITE FROM?
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: WRITE and WRITE FROM in COBOL?

Post by zprogrammer »

From the Manual

http://publibz.boulder.ibm.com/cgi-bin/ ... 0821081020
FROM phrase The result of the execution of the WRITE statement with the FROM identifier-1 phrase is equivalent to the execution of the following statements in the order specified:
MOVE identifier-1 TO record-name-1.
WRITE record-name-1.
The MOVE is performed according to the rules for a MOVE statement without the CORRESPONDING phrase.
zprogrammer
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1900
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: WRITE and WRITE FROM in COBOL?

Post by Robert Sample »

If a programmer refers to the record-area after the WRITE (not WRITE FROM), the result is unpredictable
This understanding is wrong -- attempting to access the record-area after a WRITE or WRITE FROM will yield unpredictable results, not just after the WRITE. With WRITE FROM, you can get to the last record because it is still in WORKING-STORAGE, not the record-area.
User avatar
Kishor Bag
Registered Member
Posts: 10
Joined: Thu Jan 16, 2014 4:46 pm

Re: WRITE and WRITE FROM in COBOL?

Post by Kishor Bag »

Thanks Robert. I've to get used to the terminology better.

Thanks.
dick scherrer
Former Team Member
Posts: 62
Joined: Wed Aug 07, 2013 6:43 pm

Re: WRITE and WRITE FROM in COBOL?

Post by dick scherrer »

I've to get used to the terminology better.
One of the Most Important things to do. . .

Terminology is Critical for understanding and quite often it is the terminology used that causes confusion.

We will help with terminology when we can. It is quit all right to ask when noe sure.
Hope this helps,
d
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 “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”