4 IDENTIFICATION DIVISION
IDENTIFICATION DIVISION Syntax
[{ IDENTIFICATION } DIVISION. ]
{ ~~~~~~~~~~~~~~ } ~~~~~~~~
{ ID }
~~
{ PROGRAM-ID. } { program name } .
{ ~~~~~~~~~~ } { literal-1 } [ AS { literal-2 } ] [ Type-clause ] .
{ FUNCTION-ID. } { literal-3 } [ AS literal-4 ] .
~~~~~~~~~~~ { function-name } .
{ OPTIONS. }
~~~~~~~
[ DEFAULT ROUNDED MODE IS {AWAY-FROM-ZERO }
~~~~~~~ ~~~~~~~ {NEAREST-AWAY-FROM-ZERO }
{NEAREST-EVEN }
{NEAREST-TOWARDS-ZERO }
{PROHIBITED }
{TOWARDS-GREATER }
{TOWARDS-LESSER }
{TRUNCATION }]
[ ENTRY-CONVENTION IS {COBOL }
~~~~~~~~~~~~~~~~ {EXTERN }
{STDCALL }]
[ AUTHOR. comment-1. ]
~~~~~~
[ DATE-COMPILED. comment-2. ]
~~~~~~~~~~~~~
[ DATE-MODIFIED. comment-3. ]
~~~~~~~~~~~~~
[ DATE-WRITTEN. comment-4. ]
~~~~~~~~~~~~
[ INSTALLATION. comment-5. ]
~~~~~~~~~~~~
[ REMARKS. comment-6. ]
~~~~~~~
[ SECURITY. comment-7. ]
~~~~~~~~
The
AUTHOR
,
DATE-COMPILED
,
DATE-MODIFIED
,
DATE-WRITTEN
,
INSTALLATION
,
REMARKS
and
SECURITY
paragraphs are supported by GnuCOBOL only to provide compatibility with programs written for the ANS1974 (or earlier) standards. As of the ANS1985 standard, these clauses have become obsolete and should not be used in new programs.
PROGRAM-ID Type Clause Syntax
IS [ COMMON ] [ INITIAL|RECURSIVE PROGRAM ]
~~~~~~ ~~~~~~~ ~~~~~~~~~
The identification division provides basic identification of the program by giving it a name and optionally defining some high-level characteristics via the eight pre-defined paragraphs that may be specified.
The paragraphs shown above may be coded in any sequence.
The reserved words
AS
,IS
andPROGRAM
are optional and may be included, or not, at the discretion of the programmer. The presence or absence of these words has no effect upon the program.A Type Clause may be coded only when
PROGRAM-ID
is specified. If one is coded, eitherCOMMON
,COMMON INITIAL
orCOMMON RECURSIVE
must be specified.While the actual
IDENTIFICATION DIVISION
orID DIVISION
header is optional, thePROGRAM-ID
/FUNCTION-ID
paragraphs are not; only one or the other, however, may be coded.The compiler’s
-Wobsolete
switch will cause the GnuCOBOL compiler to issue warnings messages if these (or any other obsolete syntax) is used in a program.If specified, <literal-1> must be an actual alphanumeric literal and may not be a figurative constant.
The
PROGRAM-ID
andFUNCTION-ID
paragraphs serve to identify the program to the external (i.e. operating system) environment. If there is noAS
clause present, the <program-id> will serve as that external identification. If there is anAS
clause specified, that specified literal will serve as the external identification. For the remainder of this document, that “external identification” will be referred to as the primary entry-point name.The
INITIAL
,COMMON
andRECURSIVE
words are used only within subprograms serving as subroutines. Their purposes are as follows:COMMON
should be used only within subprograms that are nested subprograms. A nested subprogram declared asCOMMON
may be called from any nested program in the source file being compiled, not just those “above” it in the nesting structure.The
RECURSIVE
clause, if any, will cause the compiler to generate different object code for the subprogram that will enable it to invoke itself and to properly return back to the program that invoked it.User-defined functions (i.e.
FUNCTION-ID
) are always recursive.The
INITIAL
clause, if specified, guarantees the subprogram will be in its initial (i.e. compiled) state each and every time it is executed, not just the first time.