Procedure Division (cont.) [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Procedure Division (cont.)
The ENTER Statement
Function
The ENTER statement provides a means of allowing the use of more than one
language in the same program.
________________________________________________________________________
|(ANS85) |
|The ENTER statement is classed as an obsolete element in the ANSI'85 |
|standard and is scheduled to be deleted from the next full revision of|
|the ANSI Standard. |
________________________________________________________________________
________________________________________________________________________
|(MF) |
|All dialects within this COBOL implementation support this syntax for |
|documentation purposes only. Refer to your COBOL Reference for |
|details on using the FLAGSTD directive to detect all occurrences of |
|this syntax. |
________________________________________________________________________
________________________________________________________________________
|(XOPEN) |
|Although it is a part of the standard COBOL definition, this feature |
|is explicitly excluded from the X/Open COBOL language definitions |
|and should not be used in an X/Open COBOL conforming source |
|program. |
________________________________________________________________________
General Format
ENTER language-name [routine-name] .
Syntax Rule
Language-name and routine-name can be any user-defined word or
alphanumeric literal.
General Rule
This statement is treated as for documentation purposes only. Access to
other languages can be achieved by means of the CALL statement.
________________________________________________________________________
|The ENTRY Statement |
| |
|(OSVS) (VSC2) (MF) |
| |
|Function |
| |
|The ENTRY statement establishes an alternate entry point into a called|
|COBOL program. |
________________________________________________________________________
General Format
(MF)
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
|Syntax Rules |
| |
| |
| 1. Entry-name can be any alphanumeric literal, of which only the |
| first 8 characters are significant. |
| |
| This rule is not enforced. (MF) |
| |
| 2. The entry-name must not be the name of the called program in |
| which it appears, but it must follow the same rules of |
| formation. |
| |
| This rule is not enforced. (OSVS) (MF) |
| |
| 3. All entry-names within any program must be unique in the first |
| eight characters. |
| |
| This rule is not enforced. (MF) |
| |
| 4. The ENTRY statement can not be used in a program that is nested|
| within another program. |
| |
| 5. The identifier can be a USAGE DISPLAY-1 (DBCS), floating-point |
| or USAGE IS POINTER item. |
| |
| |
| |
|6. Data-name-1 must be defined as a data item in the Linkage Section|
| of the program in which this header appears. (MF) |
| |
|7. `$$The size of the entry is defined by the number of bytes |
| defined for data-name-1 in its PICTURE clause and USAGE. |
| The size of the entry is defined by the number of bytes |
| defined for data-name-1 in its PICTURE clause and USAGE.'' |
| (MF) |
| |
________________________________________________________________________
________________________________________________________________________
|(MF) |
| |
| |
| |
|8. Data-name-1 of the ENTRY statement in the called program and |
| data-name-1 in the calling program must define an equal number of|
| character positions, although their names need not be the same. |
| If their definitions are not identical unpredictable results can |
| occur as the data space which is not allocated to the data item |
| can be corrupted. |
| |
|9. Items used in the BY VALUE phrase are restricted to numeric |
| values that are: |
| |
| |
| a. Binary (USAGE Binary, COMP, COMP-4, COMP-5, and |
| COMP-X) |
| |
| b. integers |
| |
| c. pointers (USAGE POINTER or PROCEDURE-POINTER) |
| |
| d. ADDRESS OF identifier (any ADDRESS OF special register) |
| |
| e. LENGTH OF identifier (any LENGTH OF special register) |
| |
|10. The size of BY VALUE fields is limited to four bytes. Specific |
| operating systems or COBOL implementations can have different |
| limits. See your COBOL System Reference for additional |
| information. |
| |
|11. For a system in which COMP-5 fields are stored in "reverse order"|
| an implicit (invisible to the program/programmer) move will occur|
| if the VALUE field is defined as BINARY, COMP, COMP-4, or |
| COMP-X. |
| |
|12. It is the programmer's responsibility to ensure that fields |
| referenced in a BY VALUE phrase agree as to size and USAGE in |
| both the calling and called program. In cases where these rules |
| are violated, results are unpredictable. However, there will be |
| no compile-time verification of this. |
| |
| In cases such as COMP-5 and Pointer data items where, in |
| some COBOL systems, they are implicitly identical storage |
| definitions in the current implementation, mixing these different|
| USAGEs in the calling and called programs may currently |
| give the desired results, but upward compatibility is not |
| guaranteed. |
| |
________________________________________________________________________
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
|General Rules |
| |
| |
| 1. When a CALL statement naming the alternate entry point is |
| executed in a calling program, control is transferred to the |
| next executable statement following the ENTRY statement in the |
| called program. |
| |
| 2. Your COBOL system must be able to locate the program containing|
| the entry point when the entry point is called. Refer to your |
| COBOL System Reference for details. |
| |
| For dynamic loading, the called program can be in a file on |
| disk, in which case it must have been called previously in the |
| run-unit using its program-id; or it can be in a library that |
| has been opened previously in the run-unit using the CALL |
| statement (see the section The CALL Statement earlier in this |
| chapter). (MF) |
| |
| 3. See the section "The PROCEDURE DIVISION Header" earlier in |
| this chapter for a discussion of the significance of the |
| USING phrase and rules for definition of identifier-1, et |
| cetera. |
| |
| 4. When an 01-level item in the Linkage Section has been |
| referenced in a previously called ENTRY point or PROCEDURE |
| DIVISION USING statement, but is not included in the current |
| ENTRY USING statement, addressibility is retained from the |
| previous call if the subprogram has not been cancelled by |
| an intervening action of the main program and if the |
| STICKY-LINKAGE directive has been set. See your COBOL System |
| Reference for details. (MF) |
________________________________________________________________________
________________________________________________________________________
|The EVALUATE Statement |
| |
|(ANS85) |
| |
|Function The EVALUATE statement describes a multi-branch, multi-join |
|structure. It can cause multiple conditions to be evaluated. The |
|subsequent action of the object program depends on the results of |
|these evaluations. |
________________________________________________________________________
General Format
(ANS85)
________________________________________________________________________
|(ANS85) |
| |
|Syntax Rules |
| |
| |
| 1. The operands or the words TRUE and FALSE which appear |
| before the first WHEN phrase of the EVALUATE statement |
| are referred to individually as selection subjects and |
| collectively, for all those specified, as the set of selection |
| subjects. |
| |
| 2. The operands or the words TRUE, FALSE, and ANY which appear in |
| a WHEN phrase of an EVALUATE statement are referred to |
| individually as selection objects and collectively, for all |
| those specified in a single WHEN phrase, as the set of |
| selection objects. |
| |
| 3. The words THROUGH and THRU are equivalent. |
| |
| 4. Two operands connected by a THROUGH phrase must be of the same |
| class. The two operands thus connected constitute a single |
| selection object. |
| |
| 5. The number of selection objects within each set of selection |
| objects must be equal to the number of selection subjects. |
| |
| 6. Each selection object within a set of selection objects must |
| correspond to the selection subject having the same ordinal |
| position within the set of selection subjects according to the |
| following rules: |
| |
| |
| a. Identifiers, literals, or arithmetic expressions |
| appearing within a selection object must be valid |
| operands for comparison to the corresponding operand in |
| the set of selection subjects. (See the section |
| "Relation Condition" earlier in this chapter.) |
| |
| b. Condition-1, condition-2, or the words TRUE or FALSE |
| appearing as a selection object must correspond to a |
| conditional expression or the words TRUE or FALSE in the|
| set of selection subjects. |
| |
| c. The word ANY can correspond to a selection subject of |
| any type. |
| |
| d. Where identifiers are permitted, they can reference |
| floating-point data items. (MF) (VSC2) |
| |
| e. Where numeric literals are permitted, floating-point |
| literals are permitted. (MF) (VSC2) |
| |
| f. Where identifiers are permitted, they can reference |
| pointer data items. (MF) (VSC2) |
________________________________________________________________________
________________________________________________________________________
|(ANS85) |
|[REV BEG] |
| |
| |
|7. If partial-expression-1 or partial-expression-2 is specified as a|
| selection object, it must correspond to a selection subject that |
| is an identifier, a literal or an arithmetic expression. |
| Partial-expression-1 and partial-expression-2 must be a sequence |
| of COBOL words which, when following the corresponding |
| selection subject, make the resultant text a valid conditional |
| expression[REV END] |
| |
| |
|General Rules |
| |
| |
| * The execution of the EVALUATE statement operates as if each |
| selection subject and selection object were evaluated and |
| assigned a numeric or nonnumeric value, a range of numeric or |
| nonnumeric values, or a truth value. These values are |
| determined as follows: |
| |
| |
| a. Any selection subject specified by identifier-1, |
| identifier-2, and any selection object specified |
| by identifier-3, identifier-5, without either |
| the NOT or the THROUGH phrases, are assigned the |
| value and class of the data item referenced by the |
| identifier. |
| |
| b. Any selection subject specified by literal-1, |
| literal-2, and any selection object specified by |
| literal-3, literal-5, without either the NOT or |
| the THROUGH phrases, are assigned the value and |
| class of the specified literal. If literal-3, |
| literal-5, is the figurative constant ZERO, it is |
| assigned the class of the corresponding selection |
| subject. |
| |
| c. Any selection subject in which expression-1, |
| expression-2, is specified as an arithmetic expression |
| and any selection object, without either the NOT or the |
| THROUGH phrases, in which arithmetic-expression-1, |
| arithmetic-expression-3, is specified are assigned a |
| numeric value according to the rules for evaluating an |
| arithmetic expression. (See the section "Arithmetic |
| Expressions" earlier in this chapter.) |
| |
| d. Any selection subject in which expression-1, |
| expression-2 is specified as a conditional expression |
| and any selection object in which condition-1, |
| condition-2, is specified are assigned a truth value |
| according to the rules for evaluating conditional |
| expressions. (See the section "Conditional Expressions"|
| earlier in this chapter.) |
| |
| e. Any selection subject or any selection object specified |
| by the words TRUE or FALSE is assigned a truth value. |
| The truth value "true" is assigned to those items |
| specified with the word TRUE, and the truth value |
| "false" is assigned to those items specified with the |
| word FALSE. |
________________________________________________________________________
________________________________________________________________________
|(ANS85) |
| |
| |
| |
| f. Any selection object specified by the word ANY is not |
| further evaluated. |
| |
| g. If the THROUGH phrase is specified for a selection object, |
| without the NOT phrase, the range of values is all values |
| which, when compared to the selection subject, are greater |
| than or equal to the first operand and less than or |
| equal to the second operand according to the rules for |
| comparison. (See the section "Relation Condition" |
| in this chapter.) If the first operand is greater |
| than the second operand, there are no values in the |
| range. |
| |
| h. If the NOT phrase is specified for a selection object, the |
| values assigned to that item are all values not equal |
| to the value, or range of values, which would have |
| been assigned to the item had the NOT phrase not been |
| specified. |
| |
| |
________________________________________________________________________
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|2. The execution of the EVALUATE statement then proceeds as if the |
| values assigned to the selection subjects and selection objects |
| were compared to determine if any WHEN phrase satisfies the |
| set of selection subjects. This comparison proceeds as |
| follows: |
| |
| |
| a. Each selection object within the set of selection objects |
| for the first WHEN phrase is compared to the selection |
| subject having the same ordinal position within the set of|
| selection subjects. |
| |
| |
| 1. If the items being compared are assigned numeric or|
| nonnumeric values, or a range of numeric or |
| nonnumeric values, the comparison is satisfied if |
| the value, or one of the range of values, |
| assigned to the selection object is equal to |
| the value assigned to the selection subject |
| according to the rules for comparison. (See the |
| section "Relation Condition" in this |
| chapter.) |
| |
| 2. If the items being compared are assigned |
| truth values, the comparison is satisfied if |
| the items are assigned the identical truth |
| value. |
| |
| 3. If the selection object being compared is specified|
| by the word ANY, the comparison is always satisfied|
| regardless of the value of the selection |
| subject. |
| |
| b. If the above comparison is satisfied for every selection |
| object within the set of selection objects being compared,|
| the WHEN phrase containing that set of selection objects |
| is selected as the one satisfying the set of selection |
| subjects. |
| |
| c. If the above comparison is not satisfied for one or more |
| selection objects within the set of selection objects |
| being compared, that set of selection objects does not |
| satisfy the set of selection subjects. |
| |
| d. This procedure is repeated for subsequent sets of |
| selection objects, in the order of their appearance in the|
| source program, until either a WHEN phrase satisfying the |
| set of selection subjects is selected or until all sets of|
| selection objects are exhausted. |
| |
________________________________________________________________________
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|3. After the comparison operation is completed, execution of the |
| EVALUATE statement proceeds as follows: |
| |
| |
| a. If a WHEN phrase is selected, execution continues with the|
| first imperative-statement-1 following the selected WHEN |
| phrase. |
| |
| b. If no WHEN phrase is selected and a WHEN OTHER |
| phrase is specified, execution continues with |
| imperative-statement-2. |
| |
| c. The scope of execution of the EVALUATE statement is |
| terminated when execution reaches the end of the scope of |
| the selected WHEN phrase or WHEN OTHER phrase or |
| when no WHEN phrase is selected and no WHEN OTHER |
| phrase is specified. (See the section "Explicit and |
| Implicit Scope Terminators" in the chapter COBOL |
| Concepts.) |
| [REV BEG] |
| |
| |
|4. If the selection object is specified by partial-expression-1 or |
| partial-expression-2, the corresponding selection subject is |
| considered to be the word TRUE. The selection object is |
| considered to be condition-1 or condition-2 respectively, where |
| condition-1 or condition-2 is the conditional expression |
| resulting from partial expression-1 or partial-expression-2 |
| following the original corresponding selection-subject-1 or |
| selection-subject-2 respectively.[REV END] |
| |
________________________________________________________________________
________________________________________________________________________
|The EXAMINE Statement |
| |
|(OSVS) |
| |
|Function |
| |
|The EXAMINE statement replaces or counts the number of occurrences of |
|a given character in a data item. |
________________________________________________________________________
Format 1
General Formats
Format 2
________________________________________________________________________
|(OSVS) |
| |
|Syntax Rules |
| |
| |
| |
|1. The identifier must be described, explicitly or implicitly, as |
| USAGE IS DISPLAY. |
| |
|2. Each literal must consist of a single character. If identifier |
| is a numeric item, the literals must be numeric literals, |
| nonnumeric literals whose value is a single numeric digit, |
| or the figurative constant ZERO. If identifier belongs |
| to any other class, then the literals can be numeric or |
| nonnumeric, or any figurative constant without the word |
| ALL. |
| |
________________________________________________________________________
________________________________________________________________________
|(OSVS) |
| |
|General Rules |
| |
| |
| |
|1. Examination proceeds as follows: |
| |
| |
| a. For nonnumeric data items, examination starts at the |
| leftmost character and proceeds to the right. Each |
| character in the data item specified by the identifier is |
| examined in turn. |
| |
| b. If a data item referred to by the EXAMINE statement is |
| numeric, it must consist of numeric characters and can |
| possess an operational sign. Examination starts at the |
| leftmost character (excluding the sign) and proceeds to |
| the right. Each character except the sign is examined in |
| turn. Regardless of where the sign is physically |
| located, it is completely ignored by the EXAMINE |
| statement. |
| |
|2. The TALLYING option creates an integral count which replaces the |
| value of a special register called TALLY. The count represents |
| the number of: |
| |
| |
| a. Characters not equal to literal-1 encountered before the |
| first occurrence of literal-1 when the UNTIL FIRST option |
| is used. |
| |
| b. Occurrences of literal-1 when the ALL option is |
| used. |
| |
| c. Occurrences of literal-1 prior to encountering a character|
| other than literal-1 when the LEADING option is |
| used. |
| |
|3. When either of the REPLACING options is used, the replacement |
| rules are as follows: |
| |
| |
| a. When the ALL option is used, then literal-2 is substituted|
| for each occurrence of literal-1. |
| |
| b. When the LEADING option is used, the substitution of |
| literal-2 terminates as soon as a character other than |
| literal-1 or when the right-hand boundary of the data item|
| is encountered. |
| |
| c. When the FIRST option is used, the first occurrence of |
| literal-1 is replaced by literal-2. |
| |
| d. When the UNTIL FIRST option is used, the substitution of |
| literal-2 terminates as soon as literal-1 or the |
| right-hand boundary of the data item is encountered. |
| |
________________________________________________________________________
________________________________________________________________________
|The EXEC(UTE) Statement |
| |
|(MF) |
| |
|Function |
| |
|The EXEC(UTE) statement is provided as a linkage mechanism to allow |
|control to be passed to non-COBOL sub-systems. |
| |
|General Format |
| |
| EXEC[UTE] text-name text-data END-EXEC |
| |
|Syntax Rule Text-data can be any textual data not containing the |
|string END-EXEC. |
| |
|General Rule |
| |
|The statement will be compiled as a CALL "text-name" USING |
|text-data-buffer statement (see the section The CALL Statement ) |
|earlier in this chapter, where text-data-buffer contains all the |
|text-data from the EXEC statement (space compressed) for further |
|parsing by the CALLed program text-name. |
| |
|This means that the called subprogram (text-name) will be passed a |
|text string which includes the entire COBOL statement beginning with |
|the EXEC(ute) verb and ending with the END-EXEC phrase. The |
|called program must parse and then process all of the included |
|information. |
| |
|If an identifier-name is included within text-data, then it is the |
|name of the identifier, not the value of the data within the |
|identifier that is passed to the subprogram. |
________________________________________________________________________
________________________________________________________________________
|The EXHIBIT Statement |
| |
|(OSVS) (MF) |
| |
|Function |
| |
|The EXHIBIT statement causes an (optionally conditional) display of |
|the literals, and/or identifiers (optionally preceded by the |
|identifier name) specified in the statement. |
________________________________________________________________________
General Format
________________________________________________________________________
|(OSVS) (MF) |
| |
|Syntax Rules |
| |
| |
| 1. Each identifier specified in the EXHIBIT statement can be any |
| class of data. TALLY and RETURN-CODE are the only special |
| registers that can be used as identifiers. |
| |
| 2. CHANGED and NAMED can both be omitted. |
| |
|General Rules |
| |
| |
| 1. Literals and identifiers displayed by the EXHIBIT statement are|
| separated by a space on the displayed line. |
| |
| 2. Each literal can be any figurative constant other than |
| ALL. |
| |
| 3. If the literal is numeric, it must be an unsigned integer. |
| |
| 4. Each execution of an EXHIBIT NAMED statement displays each |
| identifier or literal specified, with each identifier |
| (including any qualifiers and subscripts) followed by an "=" |
| (equal sign) and its current value. They all appear on a |
| single line in the order in which they appear in the |
| statement. |
| |
| 5. Each execution of an EXHIBIT CHANGED NAMED statement displays |
| each identifier or literal specified, with each identifier |
| (including any qualifiers and subscripts) followed by an "=" |
| (equal sign) and its current value. They all appear on a |
| single line in the order in which they appear in the |
| statement. However, the display for each identifier |
| (name and value) is conditional on the value of that |
| identifier having changed since the last execution of |
| the current EXHIBIT statement. If one or more of the |
| identifier values have not changed, neither the name nor the |
| value is printed for those identifiers. If none of the |
| identifier values has changed, and there are no literals |
| specified, there is no display (display of a blank line is |
| suppressed). |
| |
| 6. Each execution of an EXHIBIT CHANGED statement displays the |
| current value of each identifier or literal specified. They |
| all appear on a single line in the order in which they appear |
| in the statement. However, the value display for each |
| identifier is conditional on the value of that identifier |
| having changed since the last execution of the current EXHIBIT |
| statement. If one or more of the identifier values have not |
| changed, the value for those identifiers is not printed; |
| spaces are inserted instead. If none of the identifier |
| values has changed, and there are no literals specified, a |
| blank line is displayed (display of a blank line is not |
| suppressed). |
| |
| 7. Each execution of an EXHIBIT statement with neither the CHANGED|
| nor the NAMED option displays each identifier or literal |
| specified. They all appear on a single line in the order in |
| which they appear in the statement. |
________________________________________________________________________
MPE/iX 5.0 Documentation