[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU-COBOL] Procedure Division Format Question



Laura Tweedy wrote:

> Cobol Gurus!
>
> The standard claims the following are both valid format for the
> procedure division:
>
> Format 1:
> PROCEDURE DIVISION.
> { section-name SECTION.
> [ paragraph-name.
>         [sentence]... ]... }...
>
> Format 2:
> PROCEDURE DIVISION.
> { paragraph-name.
>         [sentence]... }...
>
> I read this as meaning that IF you're going to have sections, the first
> thing in the Procedure division MUST be a section line.  And, that IF
> the first thing you have is a paragraph, you can not have section
> definitions later.
>
> Is this right?  By that I mean, do most compilers enforce this?  Is it
> enforced at all?  What does the section definition mean here?  I can't
> find a description of what declaring sections in the procedure division
> gets you.

In general :
AFAIK most compilers enforce this, yes.
Sections are used to split a program in smaller parts, like functions in ALGOL,
Pascal, C and so on. Instead of functions you can't specify arguments for
sections.
Paragraphs are referred to in GO TO and PERFORM statements, and some of us
remember the ALTER as well. The use of the ALTER statement should be prohibited
as it works like run-time object code modification. Users of it should be shoot.

Sections are referred to in PERFORM statements.

Specific :
PERFORM SECTION-A means all code will be executed starting at the address of
SECTION-A until the last statement before the next section.
PERFORM PARAGRAPH-B means all code in that paragraph will be executed.
PERFORM PARAGRAPH-B THRU PARAGRAPH-C means all code from PARAGRAPH-B until and
including PARAGRAPH-C will be executed. In this case both paragraphs should be
located in the same section.

Regards,

Fred Mobach
fred@mobach.nl


--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@acm.cs.umr.edu with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@acm.cs.umr.edu.