@comment *********************************************************************
@comment ** 5. ENVIRONMENT DIVISION                                         **
@comment *********************************************************************
@newchapter{ENVIRONMENT DIVISION}
@diagram{ENVIRONMENT DIVISION,ED-Overview,ED-Overview,None}
This division defines the external computer environment in which the program will be operating.  This includes defining any files that the program may be .
@itemize @bullet
@item
If both optional sections of this division are coded, they must be coded in the sequence shown.

@item
The paragraphs within the sections may be coded in any order.

@item
These sections consist of a series of specific, pre-defined, paragraphs (@code{SOURCE-COMPUTER} and @code{OBJECT-COMPUTER}, for example),  each of which serves a specific purpose.  If no code is required for the purpose one of the paragraphs serves, the entire paragraph may be omitted.

@item
If any of the paragraphs within one of the sections are coded, the section header itself must be coded.

@item
If none of the paragraphs within one of the sections are coded, the section header itself may be omitted.

@item
If none of the sections within the environment division are coded, the @code{ENVIRONMENT DIVISION.} header itself may be omitted.
@end itemize
@comment *********************************************************************
@comment ** 5.1 CONFIGURATION SECTION                                       **
@comment *********************************************************************
@page
@newsection{CONFIGURATION SECTION}
@diagram{CONFIGURATION SECTION,ED-CONFIG-SECTION,ED-CONFIG-SECTION,None}
This section defines the computer system upon which the program is being compiled and executed and also specifies any special environmental configuration or compatibility characteristics.
@enumerate
@item
The four paragraphs in this section may be specified in any order but if not in this order, a warning will be issued.

@item
The configuration section is not allowed in a nested subprogram.  A nested program inherits the configuration section settings of its parent program.

@item
If none of the features provided by the configuration section are required by a program, the entire @code{CONFIGURATION SECTION.} header may be omitted from the program.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.1 SOURCE-COMPUTER                                           **
@comment *********************************************************************
@page
@newsubsection{SOURCE-COMPUTER}
@diagram{SOURCE-COMPUTER,ED-SOURCE-COMPUTER,ED-SOURCE-COMPUTER,None}
This paragraph defines the computer upon which the program is being compiled and provides one way in which debugging code embedded within the program may be activated.
@enumerate
@item
The reserved word @code{WITH} is optional and may be omitted.  The presence or absence of this word has no effect upon the program.

@item
This paragraph is not allowed in a nested subprogram.  A nested program inherits the @code{SOURCE-COMPUTER} settings of its parent program.

@item
The value specified for @var{computer-name} is irrelevant, provided it is a valid COBOL word that does not match any GnuCOBOL reserved word.  The @var{computer-name} value may include spaces.  This need not match the @var{computer-name} used with the @code{OBJECT-COMPUTER} paragraph, if any.

@item
The
@syntaxidx{DEBUGGING MODE} clause, if present, will inform the compiler that debugging lines (those with a @samp{D} in column 7 if Fixed Source Mode is in effect, or those prefixed with a @code{>>D} if Free Source Mode is in effect) --- normally treated as comments --- are to be compiled.

@item
Even without the @code{DEBUGGING MODE} clause, it is still possible to compile debugging lines.  Debugging lines may also be compiled by specifying the
@switchidx{-fdebugging-line} to the GnuCOBOL compiler.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.2 OBJECT-COMPUTER                                           **
@comment *********************************************************************
@page
@newsubsection{OBJECT-COMPUTER}
@diagram{OBJECT-COMPUTER,ED-OBJECT-COMPUTER,ED-OBJECT-COMPUTER,ED-OBJECT-COMPUTER}
This paragraph describes the computer upon which the program will execute.
@enumerate
@item
The @var{computer-name}, if specified, must immediately follow the @code{OBJECT-COMPUTER} paragraph name.  The remaining clauses may be coded in any sequence.

@item
The reserved words @code{CHARACTER}, @code{IS}, @code{PROGRAM} and @code{SEQUENCE} are optional and may be omitted.  The presence or absence of these words has no effect on the program.

@item
The value specified for @var{computer-name}, if any, is irrelevant provided it is a valid COBOL word that does not match any GnuCOBOL reserved word.  The @var{computer-name} may include spaces.  This need not match the @var{computer-name} used with the @code{SOURCE-COMPUTER} paragraph, if any.

@item
The @code{OBJECT-COMPUTER} paragraph is not allowed in a nested subprogram. A nested program inherits the @code{OBJECT-COMPUTER} settings of its parent program.

@item
The
@syntaxidx{COLLATING SEQUENCE} clause allows you to specify a customized character collating sequence to be used when alphanumeric values are compared to one another.  Data will still be stored in the character set native to the computer, but the logical sequence in which characters are ordered for comparison purposes can be altered from that defined by the computer's native character set.  The @var{alphabet-name-1} you specify needs to be defined in the @syntaxref{SPECIAL-NAMES} paragraph.

@item
If no @code{COLLATING SEQUENCE} clause is specified, the collating sequence implied by the character set native to the computer (usually ASCII) will be used.

@item
The optional
@syntaxidx{CLASSIFICATION} clause may be used to specify a locale for the environment in which the program will execute, for the purpose of influencing the upper-case and lower-case mappings of characters for the @syntaxref{UPPER-CASE} and @syntaxref{LOWER-CASE} intrinsic functions and the classification of characters for the @code{ALPHABETIC}, @code{ALPHABETIC-LOWER} and @code{ALPHABETIC-UPPER} class tests.  The definitions of these classes is taken from the cultural convention specification (@code{LC_CTYPE}) from the specified locale.

The meanings of the four locale specifications are as follows:
@enumerate A
@item
@var{locale-name-1} references a @syntaxrefalt{LOCALE,SPECIAL-NAMES} definition.

@item
The keyword @code{LOCALE} refers to the current locale (in effect at the time the program is executed)

@item
The keyword @code{USER-DEFAULT} references the default locale specified for the user currently executing this program.

@item
The keyword @code{SYSTEM-DEFAULT} denotes the default locale specified for the computer upon which the program is executing.
@end enumerate

@item
Absence of a @code{CLASSIFICATION} clause will cause character classification to occur according to the rules for the computer's native character set (ASCII, EBCDIC, etc.).
@end enumerate
@comment *********************************************************************
@comment ** 5.1.3 SPECIAL-NAMES                                             **
@comment *********************************************************************
@page
@newsubsection{SPECIAL-NAMES}
@diagram{SPECIAL-NAMES,ED-SPECIAL-NAMES-Info,ED-SPECIAL-NAMES-TeX,ED-SPECIAL-NAMES}
@center @var{Alphabet-Name-Clause}, @var{Class-Definition-Clause},
@center @var{Switch-Definition-Clause} and @var{Symbolic-Characters-Clause}
@center are discussed in detail in the next four sections.

The @code{SPECIAL-NAMES} paragraph provides a means for specifying various program and operating environment configuration options.
@enumerate
@item
The various clauses that may be specified within the @code{SPECIAL-NAMES} paragraph may be coded in any order.

@item
The reserved word @code{IS} is optional and may be omitted.  The presence or absence of this word has no effect upon the program.

@item
The @code{SPECIAL-NAMES} paragraph is not allowed in a nested subprogram. A nested program inherits the @code{SPECIAL-NAMES} settings of its parent program.

@item
Only the final clause specified within this paragraph should be terminated with a period.

@item
The
@syntaxidx{CALL-CONVENTION} clause allows a decimal integer, representing a series of ON/OFF switch settings, to be associated with a mnemonic name which may then be coded on a @statementref{CALL}.  The switch settings defined by this mnemonic will then control how the linkage to a subroutine invoked by the @code{CALL} statement that references @var{mnemonic-name-1} will be handled.

@item
The
@syntaxidx{CONSOLE IS CRT} clause, if specified, will cause a @statement{DISPLAY} lacking an explicit @code{UPON} clause to be treated as a @statementref{DISPLAY data-item}, and any @statement{ACCEPT} lacking a @code{FROM} clause to be treated as a @statementref{ACCEPT data-item}.

@item
If the
@syntaxidx{CRT STATUS} clause is not specified, an implicit
@syntaxidx{COB-CRT-STATUS} identifier (with a @code{PICTURE 9(4)}) will be allocated for the purpose of receiving screen @code{ACCEPT} statuses.  If @code{CRT STATUS} is specified, then @var{identifier-1} must be defined in the program as a @code{PICTURE 9(4)} field.

@item
The
@syntaxidx{CURRENCY SIGN} clause may be used to redefine the character to be used as a currency sign in a @syntaxref{PICTURE} clause.  The default currency sign is a dollar-sign (@samp{$}).  You may specify any character @i{except} @code{0}-@code{9}, @code{A}-@code{Z}, @code{a}-@code{z}, @code{+}, @code{-}, @code{,}, @code{.}, @code{*}, @code{/}, @code{;}, @code{(}, @code{)}, @code{=}, @code{\\}, quote (@samp{"}) or space.

@item
The
@syntaxidx{CURSOR IS} clause allows you to specify a 4- or 6-character data item into which the cursor screen location at the time a screen @code{ACCEPT} is satisfied.  The value will be returned as @i{rrcc} or @i{rrrccc}, depending upon the length of the specified @var{identifier-2}, where @i{rr} and @i{rrr} represent the row number (starting at zero) and @i{cc} and @i{ccc} represent the column number (also starting at zero).  There is no default data item allocated for this data if the @code{CURSOR IS} clause is not specified, and it is the programmer's responsibility to define @var{identifier-2} if the clause is specified.

@item
The
@syntaxidx{DECIMAL POINT IS COMMA} clause reverses the definition of the @samp{,} and @samp{.} characters when they are used as @code{PICTURE} editing symbols and within numeric literals.  This can have unwanted side-effects - see @ref{Punctuation}.

@item
The
@syntaxidx{LOCALE} clause may be used to associate external OS-defined locale names (@var{literal-2}) with an internal name (@var{locale-name-1}) that may then be referenced within the program.  Locale names are defined by the Operating System and/or C compiler GnuCOBOL will be utilizing on your computer.

@item
The following is the list of possible locale codes, for example, that would be available on a Windows computer running a GnuCOBOL version that was built utilizing the MinGW Unix-emulator and the GNU C compiler (gcc):
@anchoridx{LOCALE Names}
@table @strong
@item A
af_ZA, am_ET, ar_AE, ar_BH, ar_DZ, ar_EG, ar_IQ, ar_JO, ar_KW, ar_LB, ar_LY, ar_MA, ar_OM, ar_QA, ar_SA, ar_SY, ar_TN, ar_YE, arn_CL, as_IN, az_Cyrl_AZ, az_Latn_AZ

@item B
ba_R, be_BY, bg_BG, bn_IN bo_BT, bo_CN, br_FR, bs_Cyrl_BA, bs_Latn_BA

@item C
ca_ES, cs_CZ, cy_GB

@item D
da_DK, de_AT, de_CH, de_DE, de_LI, de_LU, dsb_DE, dv_MV

@item E
el_GR, en_029, en_AU, en_BZ, en_CA, en_GB, en_IE, en_IN, en_JM, en_MY en_NZ, en_PH, en_SG, en_TT, en_US, en_ZA, en_ZW, es_AR, es_BO, es_CL, es_CO, es_CR, es_DO, es_EC, es_ES, es_GT, es_HN, es_MX, es_NI, es_PA, es_PE, es_PR, es_PY, es_SV, es_US, es_UY es_VE, et_EE, eu_ES

@item F
fa_IR, fi_FI, fil_PH, fo_FO, fr_BE, fr_CA, fr_CH, fr_FR, fr_LU, fr_MC, fy_NL

@item G
ga_IE, gbz_AF, gl_ES, gsw_FR, gu_IN

@item H
ha_Latn_NG, he_IL, hi_IN, hr_BA, hr_HR, hu_HU, hy_AM

@item I
id_ID, ig_NG, ii_CN, is_IS, it_CH, it_IT, iu_Cans_CA, iu_Latn_CA

@item J
ja_JP

@item K
ka_GE, kh_KH, kk_KZ, kl_GL, kn_IN, ko_KR, kok_IN, ky_KG

@item L
lb_LU, lo_LA, lt_LT, lv_LV

@item M
mi_NZ, mk_MK, ml_IN, mn_Cyrl_MN, mn_Mong_CN moh_CA, mr_IN, ms_BN, ms_MY, mt_MT

@item N
nb_NO, ne_NP, nl_BE, nl_NL, nn_NO, ns_ZA

@item O
oc_FR, or_IN

@item P
pa_IN, pl_PL, ps_AF, pt_BR, pt_PT

@item Q
qut_GT, quz_BO, quz_EC, quz_PE

@item R
rm_CH, ro_RO, ru_RU, rw_RW

@item S
sa_IN, sah_RU, se_FI, se_NO se_SE, si_LK, sk_SK, sl_SI, sma_NO, sma_SE, smj_NO, smj_SE, smn_FI, sms_FI, sq_AL, sr_Cyrl_BA, sr_Cyrl_CS, sr_Latn_BA, sr_Latn_CS, sv_FI, sv_SE, sw_KE syr_SY

@item T
ta_IN, te_IN, tg_Cyrl_TJ, th_TH tk_TM, tmz_Latn_DZ, tn_ZA, tr_IN, tr_TR, tt_RU

@item U
ug_CN, uk_UA, ur_PK, uz_Cyrl_UZ, uz_Latn_UZ

@item V
vi_VN

@item W
wen_DE, wo_SN

@item X
xh_ZA

@item Y
yo_NG

@item Z
zh_CN, zh_HK, zh_MO, zh_SG, zh_TW, zu_ZA
@end table

@item
The
@syntaxidx{NUMERIC SIGN TRAILING SEPARATE} specification causes all signed numeric @code{USAGE DISPLAY} data items to be created as if the @code{SIGN IS TRAILING SEPARATE CHARACTER} clause was included in their definitions.

@item
The @code{@var{device-name-1} IS @var{mnemonic-name-2}} clause allows you to specify an alternate name (@var{device-name-1}) for one of the built-in GnuCOBOL device name @var{mnemonic-name-2}.  The list of device names built-into GnuCOBOL, and the physical device associated with that name, are as follows:
@table @code
@item @plainidx{CONSOLE}
This is the (screen-mode) display of the PC or Unix system.

@item  @plainidx{STDIN}
@itemx @plainidx{SYSIN}
@itemx @plainidx{SYSIPT}
These devices (they are all synonymous) represent standard system input (pipe 0).  On a PC or UNIX system, this is typically the keyboard.  The contents of a file may be delivered to a GnuCOBOL program for access via one of these device names by adding the sequence @samp{0< filename} to the end of the programs execution command.

@item @plainidx{PRINTER}
@itemx @plainidx{STDOUT}
@itemx @plainidx{SYSLIST}
@itemx @plainidx{SYSLST}
@itemx @plainidx{SYSOUT}
These devices (they are all synonymous) represent standard system output (pipe 1).  On a PC or UNIX system, this is typically the display.  Output sent to one of these devices by a GnuCOBOL program can be sent to a file by adding the sequence @samp{1> filename} to the end of the programs execution command.

@item @plainidx{STDERR}
@itemx @plainidx{SYSERR}
These devices (they are synonymous) represent standard system error output (pipe 2).  On a PC or UNIX system, this is typically the display.  Output sent to one of these devices by a GnuCOBOL program can be sent to a file by adding the sequence @samp{2> filename} to the end of the programs execution command.
@end table
@item
The @code{@var{feature-name-1} IS @var{mnemonic-name-3}} clause allow for mnemonic names to be assigned to up to the 13 printer channel (i.e. vertical page positioning) position feature names @code{C@var{nn}} (@code{@var{nn}=01-12}) and @code{CSP}.  Once a channel position has been assigned a mnemonic name, statements of the form @code{WRITE @var{record-name} AFTER ADVANCING @var{mnemonic-name-3}} may be coded to write the specified print record at the channel position assigned to @var{mnemonic-name-3}.

Printers supporting channel positioning are generally mainframe-type line printers.  When writing to printers that do not support channel positioning, a formfeed will be issued to the printer.

The @code{CSP} positioning option stands for ``No Spacing''.  Testing on a MinGW build of GnuCOBOL shows that this too results in a formfeed being issued.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.3.1 Alphabet-Name-Clause                                    **
@comment *********************************************************************
@page
@newsubsubsection{Alphabet-Name-Clause}
@diagram{SPECIAL-NAMES Alphabet-Clause,ED-SPECIAL-NAMES-AN-Info,ED-SPECIAL-NAMES-AN-TeX,None}
@diagram{SPECIAL-NAMES ALPHABET Literal-Clause,ED-SPECIAL-NAMES-L-Info,ED-SPECIAL-NAMES-L-TeX,None}
The
@syntaxidx{ALPHABET} clause relates @var{alphabet-name-1} to a specified character code set or collating sequence, including one you define yourself using the @var{literal-1} option.
@enumerate
@item
The reserved word @code{IS} is optional and may be omitted.  The presence or absence of this word has no effect upon the program.

@item
The reserved words @code{THRU} and @code{THROUGH} are interchangeable.

@item
GnuCOBOL considers
@syntaxidx{ASCII},
@syntaxidx{STANDARD-1} and
@syntaxidx{STANDARD-2} to be interchangeable.

@item
@syntaxidx{NATIVE} specifies the system default character set.

@item
The following points apply to using the @var{literal-n} specifications to compose a custom character set:
@enumerate A
@item
The @var{literal-n} values are either integers or alphanumeric quoted characters.  These represent a single character in the @code{NATIVE} character set, either by its actual text value (alphanumeric quoted character) or by ordinal position in the @code{NATIVE} character set (integer),

@item
The sequence in which characters are defined in this clause specifies the relative order those characters should have when comparisons are made using this alphabet.

@item
Character positions in this list do not affect the actual binary storage values used for the characters.  Binary values will still be those of the @code{NATIVE} character set.

@item
You may specify any of the figurative constants @code{SPACE}, @code{SPACES}, @code{ZERO}, @code{ZEROS}, @code{ZEROES}, @code{QUOTE}, @code{QUOTES}, @code{HIGH-VALUE}, @code{HIGH-VALUES}, @code{LOW-VALUE} or @code{LOW-VALUES} for any of the @var{literal-1}, @var{literal-2} or @var{literal-3} specifications.
@end enumerate
@item Once you have defined an alphabet name, that alphabet name may be used on specifications in @code{CODE-SET}, @code{COLLATING SEQUENCE}, or @code{SYMBOLIC CHARACTERS} clauses elsewhere in the program.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.3.2 Class-Definition-Clause                                 **
@comment *********************************************************************
@page
@newsubsubsection{Class-Definition-Clause}
@diagram{SPECIAL-NAMES Class-Definition-Clause,ED-SPECIAL-NAMES-CD,ED-SPECIAL-NAMES-CD,None}
@enumerate
@item
The reserved word @code{IS} is optional and may be omitted.  The presence or absence of this word has no effect upon the program.

@item
The reserved words @code{THRU} and @code{THROUGH} are interchangeable.

@item
 Both @var{literal-1} and @var{literal-2} must be alphanumeric literals of length 1.

@item
 The literal(s) specified on this clause define the possible characters that may be found in a data item's value in order to be considered part of the class.

@item
For example, the following defines a class called @code{Hexadecimal}, the definition of which specifies the only characters that may be present in an alphanumeric data item if that data item is to be part of the @code{Hexadecimal} class:

@example
CLASS Hexadecimal IS '0' THRU '9'
                     'A' THRU 'F'
                     'a' THRU 'f'
@end example

@item
Once class @code{Hexadecimal} has been defined, program code could then use a statement such as @code{IF input-item IS Hexadecimal} to determine if the value of characters in a data item are valid according to that class.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.3.3 Switch-Definition-Clause                                **
@comment *********************************************************************
@page
@newsubsubsection{Switch-Definition-Clause}
@diagram{SPECIAL-NAMES Switch-Definition-Clause,ED-SPECIAL-NAMES-SD,ED-SPECIAL-NAMES-SD,None}
The switch-definition clause associates a condition-name with a run-time execution switch so that the status of that switch may be tested from within a program.
@enumerate
@item
The reserved words @code{IS} and @code{STATUS} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
The valid @var{switch-name-1} names are
@syntaxidx{SWITCH-n} (@code{@var{n}} = 0-36).

@item
If the program is compiled with the
@switchidx{-fsyntax-extension}, the switch names
@syntaxidx{SWn} (@code{@var{n}} = 0-15) are also valid; they correspond to @code{SWITCH-0} through @code{SWITCH-15}, respectively as well as @code{SWITCH-16} through @code{SWITCH-36}, @code{SWITCH 0} through @code{SWITCH 26} and @code{SWITCH A} through @code{SWITCH Z}.

@item
At execution time, each switch will be associated with a
@envvarruntime{COB_SWITCH_n}, where @code{@var{n}} will have the value @samp{0} through @samp{15}.  Any of these sixteen environment variables that have the value @code{ON} (regardless of upper- or lower-case value) will be considered to be set ``on''.  Any of these sixteen environment variables having no value at all or a value other than @code{ON} will be considered @code{OFF}.

@item
Each specified switch must have at least one of a @code{IS @var{mnemonic-name-1}}, @code{ON STATUS} or an @code{OFF STATUS} option defined for it, otherwise there will be no way to reference the switch from within a GnuCOBOL program.

@item
The @code{IS @var{mnemonic-name-1}} syntax provides a means for setting the switch to either an @code{ON} or @code{OFF} value via the @statementref{SET}.

@item
The
@syntaxidx{ON STATUS} and
@syntaxidx{OFF STATUS} syntax provides a way of associating a condition-name with either the on or off status of the switch, so that status may be tested at execution time via the @statementref{IF}.
@end enumerate
@comment *********************************************************************
@comment ** 5.1.3.4 Symbolic-Characters-Clause                              **
@comment *********************************************************************
@page
@newsubsubsection{Symbolic-Characters-Clause}
@diagram{SPECIAL-NAMES-Symbolic-Characters-Clause,ED-SPECIAL-NAMES-SC,ED-SPECIAL-NAMES-SC,None}
This clause may be used to define your own figurative constants.
@enumerate
@item
The reserved words @code{ARE}, @code{CHARACTERS} and @code{IS} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
@raggedright
There must be exactly as many @var{integer-1} values specified as there are
@* @var{symbolic-character-1} names.
@end raggedright

@item
Each symbolic character name will be associated with the corresponding @var{integer-1}@sup{th} character in the alphabet named in the @code{IN} clause.  The integer values are selecting characters from the alphabet by their ordinal position and not by their numeric value; thus, an integer of 15 will select the 15@sup{th} character in the specified alphabet, regardless of the actual numeric value of the bit pattern that constitutes that character.

@item
If no @var{alphabet-name-1} is specified, the systems native character set will be assumed.

@item
The following two code examples define the same set of figurative constant names for five ASCII control characters (assuming that ASCII is the system's native character set).  The two examples are identical in their effects, even though the way the figurative constants are defined is different.

@table @i
@item Individually
@example
@group
SYMBOLIC CHARACTERS NUL IS 1
                    SOH IS 2
                    BEL IS 8
                    DC1 IS 18
                    DC2 IS 19
@end group
@end example

@item Respectively
@example
@group
SYMBOLIC CHARACTERS NUL SOH BEL DC1 DC2
                ARE   1   2   8  18  19
@end group
@end example
@end table
@end enumerate
@comment *********************************************************************
@comment ** 5.1.4 REPOSITORY                                                **
@comment *********************************************************************
@page
@newsubsection{REPOSITORY}
@diagram{REPOSITORY,ED-REPOSITORY,ED-REPOSITORY,None}
The REPOSITORY paragraph provides a way to control access to the various built-in intrinsic functions and any user defined functions that your program will be using.
@enumerate
@item
The @code{REPOSITORY} paragraph is not allowed in a nested subprogram. A nested program inherits the @code{REPOSITORY} settings of its parent program.

@item
The
@syntaxidx{INTRINSIC} clause allows you to flag one or more (or
@syntaxidx{ALL}) built-in intrinsic functions as being usable without the need to code the keyword
@syntaxidx{FUNCTION} in front of the function names.

@item
As an alternative to using the
@syntaxidx{ALL INTRINSIC} clause, you may instead compile your GnuCOBOL programs using the
@switchidx{-fintrinsics=ALL}.

@item
The @var{function-prototype-name-1} option is required to specify the name of a user-defined function your program will be using.  Optionally, should you desire, you may specify an alias name by which you will reference that user-defined function.  Should you wish, you may also use the @code{AS} clause to provide an alias name for a built-in intrinsic function.

@item
The following example
@itemize @bullet
@item
enables all intrinsic functions to be specified without the use of the @code{FUNCTION} keyword,

@item
names two user-defined functions named @code{MY-FUNCTION-1} and @code{MY-FUNCTION-2} that will be used by the program and

@item
specifies the alias names @code{SIGMA} for the intrinsic function @code{STANDARD-DEVIATION} and @code{MF2} for @code{MY-FUNCTION-2}.
@end itemize

@example
REPOSITORY.
    FUNCTION ALL INTRINSIC
    FUNCTION MY-FUNCTION-1
    FUNCTION MY-FUNCTION-2 AS "MF2"
    FUNCTION STANDARD-DEVIATION AS "SIGMA".
@end example
@end enumerate

@strong{A special note about user-defined functions} --- because you must name a user-defined function that your program will be using in the @code{REPOSITORY} paragraph, you may always reference that function from your program's procedure division without needing to use the @code{FUNCTION} keyword.
@comment *********************************************************************
@comment ** 5.2 INPUT-OUTPUT SECTION                                        **
@comment *********************************************************************
@page
@newsection{INPUT-OUTPUT SECTION}
@diagram{INPUT-OUTPUT SECTION,ED-IO-SECTION,ED-IO-SECTION,None}
The @code{INPUT-OUTPUT} section provides for the definition of any files the program will be accessing as well as control of the I/O buffering process against those files through the @code{FILE-CONTROL} and @code{I-O-CONTROL} paragraphs, respectively.
@enumerate
@item
As the diagram shows, there are three types of statements that may occur in the two paragraphs of this section.  If none of the statements are coded in a particular paragraph, the paragraph itself may be omitted, otherwise it is required.

@item
If neither paragraph is coded, the @code{INPUT-OUTPUT SECTION.} header itself may be omitted, otherwise it is normally required.

@item
If the compiler @i{configuration file} (@pxref{Compiler Configuration Files})
you are using has @code{relaxed-syntax-check} set to @samp{yes}, the @code{FILE-CONTROL} and @code{I-O-CONTROL} paragraphs may be specified without the @code{INPUT-OUTPUT SECTION} header having been coded.

@item
If both statement types are coded in the @code{I-O-CONTROL} paragraph, the order in which those statements are coded is irrelevant.
@end enumerate
@comment *********************************************************************
@comment ** 5.2.1 SELECT Statement                                          **
@comment *********************************************************************
@page
@newsubsection{SELECT}
@diagram{SELECT Statement,ED-SELECT,ED-SELECT,ED-SELECT}
The @statement{SELECT} creates a definition of a file and links that COBOL definition to the external operating system environment.
@enumerate
@item
The reserved words @code{AREAS}, @code{IS}, @code{MODE}, @code{OTHER}, @code{SEQUENCE}, @code{TO}, @code{USING} and @code{WITH} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
After @var{file-name-1}, the various clauses may be coded in any sequence.

@item
A period must follow the last coded clause.

@item
The
@syntaxidx{OPTIONAL} clause, to be used only for files that will be used to provide input data to the program, indicates the file may or may not actually be available at run-time.  Attempts to @code{OPEN} an @code{OPTIONAL} file when the file does not exist will receive a special non-fatal file status value (see status 05 in the list of file status values below) indicating the file is not available; a subsequent attempt to @code{READ} that file will return an @code{AT END} (end-of-file) condition.  Optionally, files may be designated as @code{NOT OPTIONAL}, if desired.  This is useful when specifying the compiler's
@switchidx{-foptional-file}, which automatically makes all files @code{OPTIONAL} except for those explicitly declared as @code{NOT OPTIONAL}.

@item
The @var{file-name-1} value that you specify will be the name by which you will reference the file within your program.  This name should be formed according to the rules for user-defined names (@pxref{User-Defined Words}).

@item
The optional @code{ASSIGN} clause specifies how --- at runtime, when @var{file-name-1} is opened --- either a logical device (@code{STDIN}, @code{STDOUT}) or a file anywhere in one of the currently-mounted file systems will be associated with @var{file-name-1}, as follows:
@enumerate A
@item
There are three components to the @code{ASSIGN} clause:
@table @code
@item @var{Type}
@code{EXTERNAL}, @code{DYNAMIC} or neither

@item @var{Device}
the list of device choices

@item @var{Locator}
shown as a choice between @var{identifier-1}, @var{word-1} and @var{literal-1}.
@end table

@item
@code{ASSIGN TO DISC @var{file-name-1}} will be assumed if there is no @code{ASSIGN} clause on a @code{SELECT}.

@item
If an @code{ASSIGN} clause is coded without a @var{Device}, the device @code{DISC} will be assumed.

@item
If a @var{Locator} clause is coded, the COBOL file @var{file-name-1} will be attached to a data file within any file system that is mounted and available to the executing program at the time @var{file-name-1} is opened.  How that file is identified varies, depending upon the specified @var{Locator}, as follows:
@enumerate a
@item
If @var{literal-1} is coded, the value of the literal will serve as the File Location String that will identify the data file.

@item
If @var{identifier-1} is coded, the value of the identifier will serve as the File Location String that will identify the data file.

@item
If @var{word-1} (a syntactically valid word not duplicating a reserved or user-defined word) is coded, and a @var{Type} is @code{EXTERNAL}, then @var{word-1} itself will serve as the File Location String that will identify the data file.  If, however, a @var{Type} of @code{EXTERNAL} was @i{not} specified, the compiler will create a @code{PIC X(1024)} data item named @var{word-1} within the program; the contents of that data item at the time the program opens @var{file-name-1} will then serve as the File Location String that will identify the data file.

@item
File Location Strings will be discussed shortly.
@end enumerate

@item
If no @var{Locator} is coded, @var{file-name-1} will be attached to a logical device or a file based upon the specified (or implied) @var{Device}, as follows:
@enumerate a
@item
@code{DISC} or @code{DISK} will assume an attachment to a file named @var{file-name-1} in whatever directory is current at the time the file is opened.

@item
@code{DISPLAY} will assume an attachment to the @code{STDOUT} logical device; these files should only be used for output.

@item
@code{KEYBOARD} will assume an attachment to the @code{STDIN} logical device; these files should only be used for input.

@item
@code{PRINTER} will assume an attachment to the @code{LPT1} logical device/port; these files should only be used for output.

@item
@code{RANDOM} or @code{TAPE} will behave exactly as @code{DISC} does.  These two additional @var{Device}s are provided to facilitate the compilation of COBOL source from other COBOL implementations.
@end enumerate

@item
The @code{LINE ADVANCING} device @i{requires} that a @var{Locator} be specified; these files should only be used for output.  A COBOL Line Advancing file will allow carriage-control characters such as line-feeds and form-feeds to be written to the attached operating system file, via the @code{ADVANCING} clause of the @statementref{WRITE}.

@item
File Location Strings are used (at runtime) to identify the path and filename to the data file that must be attached to @var{file-name-1} when that file is opened.

@item
If the compiler @i{configuration file} (@pxref{Compiler Configuration Files}) you used to compile the program with had a @code{filename-mapping} value of @code{yes}, the GnuCOBOL runtime system will first attempt to identify a currently-defined environment variable whose value will serve as the data file's path and filename, as follows:
@enumerate a
@item
If the compiler @i{configuration file} (@pxref{Compiler Configuration Files}) (@pxref{Compiler Configuration Files}) you used to compile the program specified @code{mf} as the @code{assign-clause} value, then the File Locator String will be interpreted according to Microfocus COBOL rules --- namely, everything before the last @samp{-} in the File Locator String will be ignored; the characters after the last @samp{-} will be treated as the base of an environment variable name.  If there is no @samp{-} character in the File Locator String then the entire File Locator String will serve as the base of an environment variable name.  This is the default behaviour for every config file except @code{ibm}.

@item
If, on the other hand, the compiler @i{configuration file} (@pxref{Compiler Configuration Files}) you used to compile the program specified @code{mf} as the @code{assign-clause} value, then the File Locator String will be interpreted according to according to IBM COBOL rules --- namely, the File Locator String is expected to be of the form @code{S-@var{xxx}} or @code{AS-@var{xxx}}, in which case the @var{xxx} will be treated as the base of an environment variable name.  If there is no @samp{-} character in the File Locator String then the entire File Locator String will serve as the base of an environment variable name.

@item
Once an environment variable name base (let's refer to it as @code{@var{bbbb}}) has been determined, the runtime system will look for the first one of the following environment variables that exists, in this sequence:

@display
@env{DD_@var{bbbb}}
@env{dd_@var{bbbb}}
@env{@var{bbbb}}
@end display

Windows systems are case-insensitive with regard to environment variables, so there is no difference between the first two when using a GnuCOBOL implementation built for either Windows/MinGW or native Windows.

If an environment variable was found, its value will serve as the path and filename to the data file.
@end enumerate

@item
If no environment variable was found, or the @i{configuration file} (@pxref{Compiler Configuration Files}) used to compile the program had a @code{filename-mapping} value of @code{NO}, then the File Locator String value will serve as the path and filename to the data file.

@item
Paths and file names may be specified on an absolute (@code{C:\\Data\\datafile.dat}, @code{/Data/datafile.dat}, @dots{}) or relative to the current directory (@code{Data\\datafile.dat}, @code{Data/datafile.dat}, @dots{}) basis.
If no directory name is included (@code{datafile.dat}), the file must be in the current directory.
@end enumerate

@item
The
@syntaxidx{FILE STATUS} or
@syntaxidx{SORT STATUS} clause (they are both equivalent and only one or the other, if any, should be specified) is used to specify the name of a two-digit numeric data item into which an I/O status code will be saved after every I/O verb that is executed against the file.  This does not actually allocate the data item --- you must define the item yourself somewhere in the data division. Note that the following list is complete as of v3.2: but more can be added and any tests should include one for non zeros as a catch all. See the copy book file filestat.cpy (which may not include all of these listed status codes). See sample version lower down.
@anchoridx{File Status Codes}Possible status codes that can be returned to a @code{FILE STATUS} data item are as follows:

@c dictionary{code, definitions}
@ifhtml
@html
<div class=definitions>
@end html
@end ifhtml
@table @code

@item 00
Success

@item 02
Success (Duplicate Record Key Written)

@item 04
Success (Incomplete)

@item 05
Success (Optional File Not Found)

@item 06
Multiple records (in LS)

@item 07
Success (No Unit)

@item 09
Success LS Bad Data

@item 10
End of file reached if reading forward or beginning-of-file reached if reading backward

@item 14
Out of key range

@item 21
Key invalid

@item 22
Key already exists

@item 23
Key not found

@item 24
Key boundary violation

@item 30
Permanent I/O error

@item 31
Inconsistent filename

@item 34
Boundary violation

@item 35
File not found

@item 37
Permission denied

@item 38
Closed with lock

@item 39
Conflicting attribute

@item 41
File already open

@item 42
File not open

@item 43
Read not done

@item 44
Record overflow

@item 46
Read error

@item 47
@code{OPEN INPUT} denied (insufficient permissions to read file)

@item 48
@code{OPEN OUTPUT} denied (insufficient permissions to write to file)

@item 49
@code{OPEN I-O} denied (insufficient permissions to read and/or write file)

@item 51
Record locked

@item 52
End of page

@item 57
@code{LINAGE} bad specification (I-O linage)

@item 61
File sharing failure

@item 71
Bad character

@item 91
File not available

@enddict{}

@item
Sample copy book member, suggest that you copy this content to say FileStat-Msgs.cpy and save in your copy book folder.

@verbatim

      *>************************************************************
      *> Author: Gary L. Cutler CutlerGL@gmail.com                 *
      *>                                                           *
      *> This copybook defines an EVALUATE statement capable of    *
      *> translating two-digit FILE-STATUS codes to a message.     *
      *>                                                           *
      *> Use the REPLACING option to COPY to change the names of   *
      *> the MSG and STATUS identifiers to                         *
      *> the names your program needs.                             *
      *> chg 09/08/23 vbc for missing statuses                     *
      *> Chg 11/12/23 vbc for missing statuses, amended note above *
      *>                  to allow for copybook expansion.         *
      *>************************************************************
           EVALUATE STATUS
                WHEN 00 MOVE 'Success                  ' TO MSG
                WHEN 02 MOVE 'Success Duplicate        ' TO MSG
                WHEN 04 MOVE 'Success Incomplete       ' TO MSG
                WHEN 05 MOVE 'Success Optional, Missing' TO MSG
                when 06 move "Multiple Records LS"       to msg
                WHEN 07 MOVE 'Success No Unit          ' TO MSG
                when 09 move "Success LS Bad Data"       to msg
                WHEN 10 MOVE 'End Of File              ' TO MSG
                WHEN 14 MOVE 'Out Of Key Range         ' TO MSG
                WHEN 21 MOVE 'Key Invalid              ' TO MSG
                WHEN 22 MOVE 'Key Exists               ' TO MSG
                WHEN 23 MOVE 'Key Not Exists           ' TO MSG
                WHEN 24 MOVE 'Key Boundary violation   ' TO MSG
                WHEN 30 MOVE 'Permanent Error          ' TO MSG
                WHEN 31 MOVE 'Inconsistent Filename    ' TO MSG
                WHEN 34 MOVE 'Boundary Violation       ' TO MSG
                WHEN 35 MOVE 'File Not Found           ' TO MSG
                WHEN 37 MOVE 'Permission Denied        ' TO MSG
                WHEN 38 MOVE 'Closed With Lock         ' TO MSG
                WHEN 39 MOVE 'Conflict Attribute       ' TO MSG
                WHEN 41 MOVE 'Already Open             ' TO MSG
                WHEN 42 MOVE 'Not Open                 ' TO MSG
                WHEN 43 MOVE 'Read Not Done            ' TO MSG
                WHEN 44 MOVE 'Record Overflow          ' TO MSG
                WHEN 46 MOVE 'Read Error               ' TO MSG
                WHEN 47 MOVE 'Input Denied             ' TO MSG
                WHEN 48 MOVE 'Output Denied            ' TO MSG
                WHEN 49 MOVE 'I/O Denied               ' TO MSG
                WHEN 51 MOVE 'Record Locked            ' TO MSG
                WHEN 52 MOVE 'End-Of-Page              ' TO MSG
                WHEN 57 MOVE 'I/O Linage               ' TO MSG
                WHEN 61 MOVE 'File Sharing Failure     ' TO MSG
                WHEN 71 MOVE 'Bad Character            ' TO MSG
                WHEN 91 MOVE 'File Not Available       ' TO MSG
                WHEN OTHER
                     MOVE "Unknown File Status         " TO MSG
           END-EVALUATE.

@end verbatim

@item One sample code defining and using this copy book in a free format program source.

@verbatim

In Working-Storage section :

 01  WS-Wor-Areas.
     03  WS-Eval-Msg     pic x(25)       value spaces.
     03  Fs-Reply        pic xx.
     03  WS-No-Care      pic x.

 .....

 01  Error-Messages.
*> System Wide
     03  SL002          pic x(31) value "SL002 Note error and hit return".


In Procedure Division :

     rewrite  CUSTOMER-Record invalid key
              display "Rewrite Customer Rec " at line ws-23-lines col 1
              display CUSTOMER-FILE-STATUS  at line WS-23-Lines  col 22
              move    CUSTOMER-FILE-STATUS to FS-Reply
              perform evaluate-message
              display ws-Eval-Msg at line ws-23-lines col 25 beep
              display SL002       at line ws-lines col 1
              accept  WS-No-Care  at line ws-lines col 33
              display space    at line ws-23-lines col 1 with erase eos
     end-rewrite

*>
 Evaluate-Message        Section.
*>==============================
*>
 copy "FileStat-Msgs.cpy" replacing MSG by ws-Eval-Msg
                                    STATUS by fs-reply.
*>
 Eval-Msg-Exit.  exit section.
*>************   ************
*>

@end verbatim

@item
The @syntaxidx{SHARING} clause defines the conditions under which the program will be willing (or not) to allow other programs executing at the same time to access the file.  @xref{File Sharing}, for the details.

@item
The
@syntaxidx{LOCK} clause defines how concurrent access to the file will be managed on a record-by-record basis.  @xref{Record Locking}, for the details.

@item
For syntax details  for the @code{ORGANIZATION} clause, see next group of paragraphs.

@item
A @code{SELECT} statement without an @code{ORGANIZATION} explicitly coded will be handled as if the following ORGANIZATION clause had been specified:

@example

ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
@end example
@end enumerate
@comment *********************************************************************
@comment ** 5.2.1.1 ORGANIZATION SEQUENTIAL                                 **
@comment *********************************************************************
@page
@newsubsubsection{ORGANIZATION SEQUENTIAL}
@diagram{ORGANIZATION SEQUENTIAL Clause,ED-SELECT-ORG-SEQ,ED-SELECT-ORG-SEQ,None}
Files declared as @code{ORGANIZATION SEQUENTIAL} will consist of records with no explicit end-of-record delimiter character sequences; records in such files are ``delineated'' by a calculated byte-offset (based on the maximum record length) into the file.
@enumerate
@item
The reserved words @code{BINARY}, @code{IS}, @code{MODE} and @code{RECORD} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
The reserved words @code{ORGANIZATION} and @code{ORGANISATION} are interchangeable.

@item
The phrase @code{ORGANIZATION IS} (and its internationalized alternative, @code{ORGANISATION IS}) is optional to provide compatibility with those (few) COBOL implementations that consider @code{ORGANIZATION} to be optional.  Most COBOL implementations do require the word @code{ORGANIZATION}, so it should be used in new programs.

@item
These files cannot be prepared with any standard text-editing or word processing software as all such programs will embed delimiter characters at the end of records (use @code{ORGANIZATION IS LINE SEQUENTIAL} instead).

@item
These files may contain either @code{USAGE DISPLAY} or @code{USAGE COMPUTATIONAL} (of any variety) data since no binary data sequence can be accidentally interpreted as an end-of-record delimiter.

@item
While records in a @code{ORGANIZATION SEQUENTIAL} file may be defined as having variable-length records, the file will be structured in such a manner as to reserve space for each record equal to the size of the largest possible record, based on the file's description in the @code{FILE SECTION}.

@item
The
@syntaxidx{ACCESS MODE SEQUENTIAL} clause is optional because, if absent, it will be assumed anyway for this type of file.  The internal structure of these files is such that they can only be processed in a sequential manner; in order to read the 100th record in such a file, for example, you first must read records 1 through 99.

@item
Sequential files are processed using the following statements:
@itemize @bullet
@item
@syntaxref{CLOSE}

@item
@syntaxref{COMMIT}

@item
@syntaxref{DELETE}

@item
@syntaxref{MERGE}

@item
@syntaxref{OPEN}

@item
@syntaxref{READ}

@item
@syntaxref{REWRITE}

@item
@syntaxref{SORT}

@item
@syntaxref{UNLOCK}

@item
@syntaxref{WRITE}
@end itemize
@end enumerate
@comment *********************************************************************
@comment ** 5.2.1.2 ORGANIZATION LINE SEQUENTIAL                            **
@comment *********************************************************************
@page
@newsubsubsection{ORGANIZATION LINE SEQUENTIAL}
@diagram{ORGANIZATION LINE SEQUENTIAL Clause,ED-SELECT-ORG-L-SEQ,ED-SELECT-ORG-L-SEQ,ED-SELECT-ORG-L-SEQ}
Files declared as @code{ORGANIZATION LINE SEQUENTIAL} will consist of records terminated by an end-of-record delimiter character or character sequence.
@enumerate
@item
The reserved words @code{CHARACTER}, @code{IS} and @code{MODE} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
The reserved words @code{ORGANIZATION} and @code{ORGANISATION} are interchangeable.

@item
The phrase @code{ORGANIZATION IS} (and its internationalized alternative, @code{ORGANISATION IS}) is optional to provide compatibility with those (few) COBOL implementations that consider that word to be optional.  Most COBOL implementations do require the word @code{ORGANIZATION}, so it should be used in new programs.

@item
This is the only @code{ORGANIZATION} valid for files that are assigned to the @code{PRINTER} device.

@item
These files may be created with any standard text-editing or word processing software capable of writing text files.  Such files MUST NOT contain any @code{USAGE COMPUTATIONAL} or @code{BINARY} (of any variety) data since such fields could accidentally contain byte sequences that could be interpreted as an end-of-record delimiter.

@item
Both fixed- and variable-length record formats are supported.

@item
The end-of-record delimiter sequence will be @code{X@samp{0A}} (an ASCII line-feed character) or a @code{X@samp{0D0A}} (an ASCII carriage-return + line-feed sequence).  The former is used on Unix implementations of GnuCOBOL (including Windows/MinGW, Windows/Cygwin and OSX implementations) while the latter would be used with native Windows implementations.

@item
When reading a @code{LINE SEQUENTIAL} file, records in excess of the size implied by the file's description in the @code{FILE SECTION} will be truncated while records shorter than that size will be padded to the right with @code{SPACES}.

@item
The
@syntaxidx{ACCESS MODE SEQUENTIAL} clause is optional because, if absent, it will be assumed anyway for this type of file.  The internal structure of these files is such that the data can only be processed in a sequential manner; in order to read the 100th record in such a file, for example, you first must read records 1 through 99.

@item
Files assigned to @code{PRINTER} or @code{CONSOLE} should be specified as @code{ORGANIZATION LINE SEQUENTIAL}.

@item
Line Sequential files are processed using the following statements:
@itemize @bullet
@item
@syntaxref{CLOSE}

@item
@syntaxref{COMMIT}

@item
@syntaxref{DELETE}

@item
@syntaxref{MERGE}

@item
@syntaxref{OPEN}

@item
@syntaxref{READ}

@item
@syntaxref{REWRITE}

@item
@syntaxref{SORT}

@item
@syntaxref{UNLOCK}

@item
@syntaxref{WRITE}
@end itemize
@end enumerate
@comment *********************************************************************
@comment ** 5.2.1.3 ORGANIZATION RELATIVE                                   **
@comment *********************************************************************
@page
@newsubsubsection{ORGANIZATION RELATIVE}
@diagram{ORGANIZATION RELATIVE Clause,ED-SELECT-ORG-REL,ED-SELECT-ORG-REL,None}
These files are files with an internal organization such that records may be processed in a sequential manner based upon their physical location in the file or in a random manner by allowing records to be read, written or updated by specifying the relative record number in the file.
@enumerate
@item
The reserved words @code{IS}, @code{KEY} and @code{MODE} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
The reserved words @code{ORGANIZATION} and @code{ORGANISATION} are interchangeable.

@item
The phrase @code{ORGANIZATION IS} (and its internationalized alternative, @code{ORGANISATION IS}) is optional to provide compatibility with those (few) COBOL implementations that consider that word to be optional.  Most COBOL implementations do require the word @code{ORGANIZATION}, so it should be used in new programs.

@item
@code{ORGANIZATION RELATIVE} files cannot be assigned to the @code{CONSOLE}, @code{DISPLAY}, @code{LINE ADVANCING} or @code{PRINTER} devices.

@item
The
@syntaxidx{RELATIVE KEY} clause is optional only if @code{ACCESS MODE SEQUENTIAL} is specified.

@item
While an @code{ORGANIZATION RELATIVE} file may be defined as having variable-length records, the file will be structured in such a manner as to reserve space for each record equal to the size of the largest possible record as defined by the file's description in the @code{FILE SECTION}.

@item
@code{ACCESS MODE SEQUENTIAL}, the default @code{ACCESS MODE} if none is specified, indicates that the records of the file will be processed in a sequential manner, according to their physical sequence in the file.

@item
@syntaxidx{ACCESS MODE RANDOM} means that records will be processed in random sequence by specifying their record number in the file every time the file is read or written.

@item
@syntaxidx{ACCESS MODE DYNAMIC} indicates the program may switch back and forth between @code{SEQUENTIAL} and @code{RANDOM} mode during execution.  The file starts out initially in @code{SEQUENTIAL} mode when first opened but the program may use the @statementref{START} to switch between sequential and random access.

@item
The
@syntaxidx{RELATIVE KEY} data item is a numeric data item that cannot be defined as a field within records of this file.  Its purpose is to return the current relative record number of a relative file that is being processed in @code{SEQUENTIAL} access mode and to serve as a key that specifies the relative record number to be read or written when processing a relative file in @code{RANDOM} access mode.

@item
Relative files are processed using the following statements:
@itemize @bullet
@item
@syntaxref{CLOSE}

@item
@syntaxref{COMMIT}

@item
@syntaxref{DELETE}

@item
@syntaxref{MERGE}, @code{ACCESS MODE RANDOM} not allowed

@item
@syntaxref{OPEN}

@item
@syntaxref{READ}

@item
@syntaxref{REWRITE}

@item
@syntaxref{SORT}, @code{ACCESS MODE RANDOM} not allowed

@item
@syntaxref{START}

@item
@syntaxref{UNLOCK}

@item
@syntaxref{WRITE}
@end itemize
@end enumerate
@comment *********************************************************************
@comment ** 5.2.1.4 ORGANIZATION INDEXED                                    **
@comment *********************************************************************
@page
@newsubsubsection{ORGANIZATION INDEXED}
@diagram{ORGANIZATION INDEXED Clause,ED-SELECT-ORG-IDX,ED-SELECT-ORG-IDX,None}
Indexed files, like relative files, may have their records processed in either a sequential or random manner.  Unlike relative files, however, the actual location of a record in an indexed file is calculated automatically based upon the value(s) of one or more alphanumeric fields within records of the file.  For example, an indexed file containing product data might use the product identification code as a record key.  This means you may read, write or update the @code{A6G4328}@sup{th} record or the @code{Z8X7723}@sup{th} record directly, based upon the product id value of those records!
@enumerate
@item
The reserved words @code{IS}, @code{KEY} and @code{MODE} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
The reserved words @code{ORGANIZATION} and @code{ORGANISATION} are interchangeable.

@item
The phrase @code{ORGANIZATION IS} (and its internationalized alternative, @code{ORGANISATION IS}) is optional to provide compatibility with those (few) COBOL implementations that consider that word to be optional.  Most COBOL implementations do require the word @code{ORGANIZATION}, so it should be used in new programs.

@item
@code{ORGANIZATION INDEXED} files cannot be assigned to @code{CONSOLE}, @code{DISPLAY}, @code{KEYBOARD}, @code{LINE ADVANCING} or @code{PRINTER}.

@item
@syntaxidx{ACCESS MODE SEQUENTIAL}, the default @code{ACCESS MODE} if none is specified,  indicates that the records of the file will be processed in a sequential manner with respect to the values of the @code{RECORD KEY} or the @code{ALTERNATE RECORD KEY} most-recently referenced on a @statementref{START}.

@item
@syntaxidx{ACCESS MODE RANDOM} means that records will be processed in random sequence by accessing the record with specific record key or alternate record key values.

@item
@syntaxidx{ACCESS MODE DYNAMIC} allows the file will be processed either in @code{RANDOM} or @code{SEQUENTIAL} mode; the program may switch between the two modes as needed.  The @code{START} statement is used to make the switch between modes.

@item
The
@syntaxidx{RECORD KEY} clause defines the field within the record used to provide the primary access to records within the file.  No two records in the file will be allowed to have the same @code{PRIMARY KEY} field value. The
@syntaxidx{SOURCE IS} clause is for use with
@syntaxidx{Split Keys}.

@item
The
@syntaxidx{ALTERNATE RECORD KEY} clause, if used, defines an additional field within the record that provides an alternate means of directly accessing records or an additional field by which the file's contents may be processed sequentially.  You have the choice of allowing records to have duplicate alternate key values, if necessary.

@item
There may be multiple @code{ALTERNATE RECORD KEY} clauses, each defining an additional alternate key for the file.

@item
Usage of the
@syntaxidx{SUPPRESS WHEN} clause is used when
@syntaxidx{Sparse Keys} are required which may take the form for a literal or spaces or zeroes.

@item
Indexed files are processed using the following statements:
@itemize @bullet
@item
@syntaxref{CLOSE}

@item
@syntaxref{COMMIT}

@item
@syntaxref{DELETE}

@item
@syntaxref{MERGE}, @code{ACCESS MODE RANDOM} not allowed

@item
@syntaxref{OPEN}

@item
@syntaxref{READ}

@item
@syntaxref{REWRITE}

@item
@syntaxref{SORT}, @code{ACCESS MODE RANDOM} not allowed

@item
@syntaxref{START}

@item
@syntaxref{UNLOCK}

@item
@syntaxref{WRITE}
@end itemize
@end enumerate
@comment *********************************************************************
@comment ** 5.2.2 SAME RECORD AREA Statement                                **
@comment *********************************************************************
@page
@newsubsection{SAME RECORD AREA}
@diagram{I-O-CONTROL SAME AREA,ED-IO-CONTROL-SAME,ED-IO-CONTROL-SAME,ED-IO-CONTROL-SAME}
The @code{SAME RECORD AREA} clause allows you to specify that multiple files should share the same input and output memory buffers.
@enumerate
@item
The reserved words @code{AREA} and @code{FOR} are optional and may be omitted.  The presence or absence of these words has no effect upon the program.

@item
This statement must be terminated with a period.

@item
While coding only a single file name (the repeated @var{file-name-1} item) is syntactically valid, this statement will have no effect upon the program unless at least two files are specified.

@item
The effect of this statement will be to cause the specified files to share the same I/O buffer in memory.  These buffers can sometimes get quite large, and by having multiple files share the same buffer memory you may significantly cut down the amount of memory the program is using (thus making ``room'' for more procedural code or data).  If you do use this feature, take care to ensure that no more than one of the specified files are ever OPEN simultaneously.
@end enumerate
@comment *********************************************************************
@comment ** 5.2.3 MULTIPLE FILE Statement                                   **
@comment *********************************************************************
@page
@newsubsection{MULTIPLE FILE}
@diagram{I-O-CONTROL MULTIPLE FILE,ED-IO-CONTROL-MULT,ED-IO-CONTROL-MULT,ED-IO-CONTROL-MULT}
@iftex
@sp 3
@center ------------------------------------------------------------
@center End of Chapter 5 --- ENVIRONMENT DIVISION
@end iftex
