Concepts of Classes of Data (Continued) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
Concepts of Classes of Data (Continued)
Condition-Name
Each condition-name must be unique, or be made unique through
qualification and/or indexing, or subscripting. If qualification is used
to make a condition-name unique, the associated conditional variable can
be used as the first qualifier. The hierarchy of names associated with
the conditional variable or the conditional variable itself must be used
to make the condition-name unique.
If references to a conditional variable require indexing or subscripting,
references to any of its condition-names require the same combination of
indexing or subscripting.
The format and restrictions on the combined use of qualification,
subscripting, and indexing of condition-names are exactly those of
"identifier" except that data-name-1 is replaced by condition-name-1.
In the general formats, "condition-name" refers to a condition-name
qualified, indexed or subscripted, as necessary.
Explicit and Implicit Specifications
There are four types of explicit and implicit specificationsthat occur in
COBOL source programs:
1. Explicit and implicit Procedure Division references.
2. Explicit and implicit transfers of control.
3. Explicit and implicit attributes.
4. For ANS85 only: Explicit and implicit scope terminators.
Explicit and Implicit Procedure Division References.
A COBOL source program can reference data items either explicitly or
implicitly in Procedure Division statements. An explicit reference
occurs when the name of the referenced item is written in a Procedure
Division statement or when the name of the referenced item is copied into
the Procedure Division by the processing of a COPY statement. An
implicit reference occurs when the item is referenced by a Procedure
Division statement without the name of the referenced item being written
in the source statement.
An implicit reference also occurs during the execution of a PERFORM
statement, when the index or data item referenced by the index-name or
identifier specified in the VARYING, AFTER or UNTIL phrase is
initialized, modified, or evaluated by the control mechanism associated
with that PERFORM statement. Such an implicit reference occurs if and
only if the data item contributes to the execution of the statement.
Explicit and Implicit Transfers of Control.
The mechanism that controls program flow transfers control:
* from sentence to sentence in the sequence in which they are
written in the source program unless an explicit transfer of
control overrides this sequence or there is no next executable
sentence to which control can be passed
* from statement to statement in the sequence in which they are
written in the source program unless an explicit transfer of
control overrides this sequence or there is no next executable
statement to which control can be passed.
The transfer of control from sentence to sentence and from statement to
statement within a sentence occurs without the writing of an explicit
Procedure Division statement and, therefore, is an implicit transfer of
control.
COBOL provides both an explicit and an implicit means of altering the
implicit control transfer mechanism.
In addition to the implicit transfer of control between consecutive
sentences and between consecutive statements, implicit transfer of
control occurs when the normal flow is altered without the execution of a
procedure branching statement. COBOL provides the four following
types of implicit control flow alterations which override the
statement-to-statement transfers of control:
1. If a paragraph is being executed under control of another COBOL
statement (for example, PERFORM, USE, SORT and MERGE) and the
paragraph is the last paragraph in the range of the controlling
statement, then an implied transfer of control occurs from the
last statement in the paragraph to the control mechanism of the
last executed controlling statement. Further, if a paragraph is
being executed under the control of a PERFORM statement which
causes iterative execution and that paragraph is the first
paragraph in the range of that PERFORM statement, an implicit
transfer of control occurs between the control mechanism
associated with that PERFORM statement and the first statement in
that paragraph for each iterative execution of the paragraph.
2. When a SORT or MERGE statement is executed, an implicit transfer
of control occurs to any associated input or output procedures.
3. When any COBOL statement is executed and results in the execution
of a declarative section, an implicit transfer of control to the
declarative section occurs.
_________________________________________________________________
NOTE Another implicit transfer of controloccurs after execution
of the declarative section, as described in item 1. above.
_________________________________________________________________
4. For MF only: In any file operation (including OPEN and CLOSE), if
a file does not have a FILE STATUS data item declared for it and
the file is not explicitly covered by a USE statement, then it is
covered by an implicit USE statement. The implied USE procedure
is equivalent to:
USE AFTER ERROR PROCEDURE ON file-name.
IF status-key-1 >= 3
DISPLAY error-message UPON CONSOLE
STOP RUN.
See your Error Messages for a definition of error messages.
An explicit transfer of control consists of an alteration of the implicit
control transfer mechanism by the execution of a procedure branching or
conditional statement. An explicit transfer of control between
statements can be caused only by the execution of a procedure branching
or conditional statement. An explicit transfer of control between
sentences can be caused only by the execution of the NEXT SENTENCE phrase
of an IF or SEARCH statement.
The execution of the procedure branching statement ALTER does not in
itself constitute an explicit transfer of control, but affects the
explicit transfer of control that occurs when the associated GO TO
statement is executed. The procedure branching statement EXIT PROGRAM
causes an explicit transfer of control when the statement is executed in
a called program.
The term "next executable sentence" is used to refer to the next COBOL
sentence to which control is either implicitly transferred according to
the rules above, or explicitly transferred as a result of execution of
the NEXT SENTENCE phrase. The next executable sentence is the first
sentence following the separator period that terminates the current
sentence. There is no next executable sentence when there is no next
executable statement as described below.
The term "next executable statement" is used to refer to the next COBOL
statement to which control is transferred according to the rules above
and the rules associated with each language element in the Procedure
Division.
There is no next executable statement following:
* the last statement in a declarative section when the paragraph in
which it appears is not being executed under the control of some
other COBOL statement
* the last statement in a program when the paragraph in which it
appears is not being executed under the control of some other
COBOL statement
* the last statement in a declarative section, when the statement is
in the range of an active PERFORM statement executed in a
different section, and this last statement of the declarative
section is not also the last statement of the procedure that is
the exit of the active PERFORM statement
* a STOP RUN statement or EXIT PROGRAM statement that transfers
control outside the COBOL program
* the END PROGRAM header.
Explicit and Implicit Attributes.
Attributes can be implicitly or explicitly specified. Any attribute
which has been explicitly specified is called an explicit attribute. If
an attribute has not been specified explicitly, then the attribute takes
on the default specification. Such an attribute is known as an implicit
attribute.
For example, the usage of a data item need not be specified, in which
case a data item's usage is DISPLAY.
Explicit and Implicit Scope Terminators (ANS85).
Scope terminatorsdelimit the scope of certain Procedure Division
statements (delimited scope statements), and are of two types: explicit
and implicit.
The explicit scope terminators are listed below:
END-ADD END-PERFORM
END-ACCEPT1 END-READ
END-CALL END-RECEIVE
END-CHAIN2 END-RETURN
END-COMPUTE END-REWRITE
END-DELETE END-SEARCH
END-DISPLAY1 END-START
END-DIVIDE END-STRING
END-EVALUATE END-SUBTRACT
END-IF END-UNSTRING
END-MULTIPLY END-WRITE
1 (MF)(XOPEN)
2 (MF)
NOTE In some cases the delimited scope statement with which an explicit
scope delimitor is paired, is determined differently for different
COBOL language specifications.
Implicit scope termination occurs:
* at the end of any sentence, where the separator period terminates
the scope of all previous statements not yet terminated
* within any statement containing another statement. The next
phrase of the containing statement (for example, ELSE, WHEN, AT
END, and so on) following the contained statement terminates the
scope of any unterminated contained statement.
MPE/iX 5.0 Documentation