For Programmers: Free Programming Magazines  


Home > Archive > Cobol > May 2004 > Examples on the USE statement









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Examples on the USE statement
Jim Morcombe

2004-05-12, 6:47 pm

I'm looking for some sample code showing nice ways to handle file I/O
errors.

I've always used a rather ugly chunk of code in one large DECLARATIVES
section that I inherited from Babbage when he was cutting Cobol code.

Now I need to repent and have some sl structured code.

Is anyone out there proud of the way they make use of the USE statement?

Jim



JerryMouse

2004-05-12, 6:47 pm

Jim Morcombe wrote:
> I'm looking for some sample code showing nice ways to handle file I/O
> errors.
>
> I've always used a rather ugly chunk of code in one large DECLARATIVES
> section that I inherited from Babbage when he was cutting Cobol code.
>
> Now I need to repent and have some sl structured code.
>
> Is anyone out there proud of the way they make use of the USE
> statement?


DECLARATIVES.
DECLAR-INPUT SECTION.
USE AFTER ERROR PROCEDURE ON INPUT CONTINUE.
DECLAR-OUTPUT SECTION.
USE AFTER ERROR PROCEDURE ON OUTPUT CONTINUE.
DECLAR-IO SECTION.
USE AFTER ERROR PROCEDURE ON I-O CONTINUE.
DECLAR-EXTEND SECTION.
USE AFTER ERROR PROCEDURE ON EXTEND CONTINUE.
END DECLARATIVES.
PROCEDUR SECTION.

Then handle everything with File Status variables. The above prevents the
compiler (Fujitsu) from generating a run-time message.


Richard

2004-05-12, 6:47 pm

"JerryMouse" <nospam@bisusa.com> wrote

> The above prevents the
> compiler (Fujitsu) from generating a run-time message.



Which can also be done much easier by having a COBOL.CBR file
containing @NoMessages or @MessOutFile=somefile, or in other similar
ways.
JerryMouse

2004-05-12, 6:47 pm

Richard wrote:
> "JerryMouse" <nospam@bisusa.com> wrote
>
>
>
> Which can also be done much easier by having a COBOL.CBR file
> containing @NoMessages or @MessOutFile=somefile, or in other similar
> ways.


1. I knew that.
2. The user asked about DECLARATIVES, not COBOL.CBR files
3. We have other reasons for avoiding the CBR file method.


Richard

2004-05-12, 6:47 pm

"JerryMouse" <nospam@bisusa.com> wrote

> 1. I knew that.
> 2. The user asked about DECLARATIVES, not COBOL.CBR files


If you are going to be picky about how replies must exactly follow the
original subject then the poster asked for "sample code showing nice
ways to handle file I/O errors", your reply did not do this.

You had merely presented a way of avoiding runtime error messages, so
did I.

> 3. We have other reasons for avoiding the CBR file method.

Jim Morcombe

2004-05-12, 6:47 pm

My inherrited chunk of code already does this, plus a bit more.

Are there any basically different methods?

For example, doesn't the standard allow for a USE statement to catch errors
on a specific file? What can be done with this rather than with File Status
tests in the Procedure division?

Jim


JerryMouse <nospam@bisusa.com> wrote in message
news:c66dnbh6SZTE8ALdRVn-sw@giganews.com...
> Jim Morcombe wrote:
>
> DECLARATIVES.
> DECLAR-INPUT SECTION.
> USE AFTER ERROR PROCEDURE ON INPUT CONTINUE.
> DECLAR-OUTPUT SECTION.
> USE AFTER ERROR PROCEDURE ON OUTPUT CONTINUE.
> DECLAR-IO SECTION.
> USE AFTER ERROR PROCEDURE ON I-O CONTINUE.
> DECLAR-EXTEND SECTION.
> USE AFTER ERROR PROCEDURE ON EXTEND CONTINUE.
> END DECLARATIVES.
> PROCEDUR SECTION.
>
> Then handle everything with File Status variables. The above prevents the
> compiler (Fujitsu) from generating a run-time message.
>
>



William M. Klein

2004-05-12, 6:47 pm

Yes, the Standard allows for USE statements on specific files. In the 2002
Standard, there can even be separate declaratives for different I-O statuses.

There is (as far as I know) really almost nothing that can be done in an ERROR
declarative that can't be done in a file-status checking routine. One possible
OBSCURE exception is that an Error Declarative may "catch" an I/O error in files
used in a SORT/MERGE USING/GIVING statement - while there is no real way to do
this with a file status check (unless you CHANGE the code to have INPUT/OUTPUT
procedures). On the other hand, some compilers don't (always) do this correctly
anyway. (IBM, for example, doesn't "go to" the USE declaratives when the
FASTSRT compiler option is in effect - which is why they document that compiler
option as "non-Standard")

--
Bill Klein
wmklein <at> ix.netcom.com
"Jim Morcombe" <jim@byronics.com.au> wrote in message
news:c7seuq$m5i$1@yeppa.connect.com.au...
> My inherrited chunk of code already does this, plus a bit more.
>
> Are there any basically different methods?
>
> For example, doesn't the standard allow for a USE statement to catch errors
> on a specific file? What can be done with this rather than with File Status
> tests in the Procedure division?
>
> Jim
>
>
> JerryMouse <nospam@bisusa.com> wrote in message
> news:c66dnbh6SZTE8ALdRVn-sw@giganews.com...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com