HP 3000 Manuals

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 STOP Statement 

Function 

The STOP statement causes a permanent or temporary suspension of the
execution of the object program.
________________________________________________________________________
|(ANS85)                                                               |
|The STOP literal 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 fully support this      |
|syntax.  Refer to your COBOL System 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, the Stop      |
|literal format 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 

Format 1 

[]
[]
Syntax Rules Format 1 1. Literal can be numeric or nonnumeric or can be any figurative constant, except ALL. 2. If literal is numeric, then it must be an unsigned integer. ________________________________________________________________________ |A signed integer is allowed. (OSVS) (VSC2) | ________________________________________________________________________ Formats 1 and 2 3. If a STOP RUN statement appears in a consecutive sequence of imperative statements within a sentence, it must appear as the last statement in that sequence. ________________________________________________________________________ |(OSVS) (VSC2) (MF) | |The STOP RUN statement does not have to be the last statement in a | |sequence, but any statements following the STOP RUN in such a sequence| |will not be executed. | ________________________________________________________________________ ________________________________________________________________________ |(MF) | | | |Format 2 | | | | | | | |4. Literal-1 must be an integer. | | | |5. Data-name-1 can be specified anywhere within the Data Division. | | | |6. The SIZE clause defines the number of bytes to be passed. The | | value is passed in COMP-5 format. | | | |7. If the SIZE clause is present, literal-2 must be numeric. | | | ________________________________________________________________________ General Rules Format 1 1. If the RUN phrase is specified, execution of the run unit ceases and control is transferred to the operating system. 2. If STOP literal is specified, the literal is communicated to the operator. Continuation of the object program begins with the execution of the next executable statement in sequence. ________________________________________________________________________ |(MF) Pressing the Enter key or equivalent continues execution. | ________________________________________________________________________ ________________________________________________________________________ |(MF) | | | |Format 2 | | | | | | | |3. The size of the GIVING fields is limited to four bytes. Specific| | operating systems or COBOL implementations can have different | | limits. See your COBOL System Reference for additional | | information. | | | |4. For a system in which COMP-5 fields are stored in "reverse order"| | an implicit (invisible to the program/programmer) move will occur| | from an implicit COMP-5 item to a receiving binary field | | upon program entry when a BY VALUE phrase is specified in | | either a PROCEDURE USING or an ENTRY USING statement if | | the VALUE field is defined as BINARY, COMP, COMP-4, or | | COMP-X. | | | |5. GIVING items are not affected by the RTNCODE-SIZE directive. | | | |6. 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. | | | ________________________________________________________________________ The STRING Statement Function The STRING statement provides juxtaposition of the partial or complete contents of two or more data items into a single data item. General Format
[]
Syntax Rules 1. Each literal can be any figurative constant without the optional word ALL. 2. All literals must be described as nonnumeric literals, and all identifiers, except identifier-4, must be described implicitly or explicitly as USAGE IS DISPLAY. 3. Identifier-3 must represent an elementary alphanumeric data item without editing symbols or the JUSTIFIED clause. 4. Identifier-4 must represent an elementary numeric integer data item of sufficient size to contain a value equal to the size plus 1 of the area referenced by identifier-3. The "P" can not be used in the PICTURE character-string of identifier-4. 5. Where identifier-1 or identifier-2 is an elementary numeric data item, it must be described as an integer without the symbol "P" in its PICTURE character-string. ________________________________________________________________________ |(MF) | | | | | | | |6. Identifier-3 must not be reference modified. | | | ________________________________________________________________________ General Rules 1. Identifier-1, or literal-1, represents the sending item. Identifier-3 represents the receiving item. 2. Literal-2, identifier-2, indicate the character(s) delimiting the move. If the SIZE phrase is used, the complete data item defined by identifier-1, or literal-1, is moved. When a figurative constant is used as the delimiter, it stands for a single character nonnumeric literal. 3. When a figurative constant is specified as literal-1, or literal-2, it refers to an implicit one-character data item whose usage is DISPLAY. 4. When the STRING statement is executed, the transfer of data is governed by the following rules: a. Those characters from literal-1, or from the contents of the data item referenced by identifier-1, are transferred to the contents of identifier-3 in accordance with the rules for alphanumeric to alphanumeric moves, except that no space filling will be provided. (See the section "The MOVE Statement" earlier in this chapter.) b. If the DELIMITED phrase is specified without the SIZE phrase, the contents of the data item referenced by identifier-1, or the value of literal-1, is transferred to the receiving data item in the sequence specified in the STRING statement beginning with the leftmost character and continuing from left to right until the end of the data item is reached, or until the character(s) specified by literal-2, or by the contents of identifier-2 are encountered. The character(s) specified by literal-2, or by the data item referenced by identifier-2 are not transferred. c. If the DELIMITED phrase is specified with the SIZE phrase, the entire contents of literal-1, or the contents of the data item referenced by identifier-1, are transferred, in the sequence specified in the STRING statement, to the data item referenced by identifier-3 until all data has been transferred or the end of the data item referenced by identifier-3 has been reached. 5. If the POINTER phrase is specified, identifier-4 is explicitly available to the programmer, who is then responsible for setting its initial value. The initial value must not be less than one. 6. If the POINTER phrase is not specified, the following General Rules apply as if the user had specified identifier-4 with an initial value of 1. 7. When characters are transferred to the data item referenced by identifier-3, the moves behave as though the characters were moved one at a time from the source into the character position of the data item referenced by identifier-3 designated by the value associated with identifier-4, and then identifier-4 was increased by one prior to the move of the next character. The value associated with identifier-4 is changed during execution of the STRING statement only by the behavior specified above. 8. At the end of execution of the STRING statement, only the portion of the data item referenced by identifier-3 that was referenced during the execution of the STRING statement is changed. All other portions of the data item referenced by identifier-3 will contain data that was present before this execution of the STRING statement. 9. Before each move of a character to the data item referenced by identifier-3, if the value associated with the data item referenced by identifier-4 is either less than one or exceeds the number of character positions in the data item referenced by identifier-3, no (further) data is transferred to the data item referenced by identifier-3, and the NOT ON OVERFLOW phrase, if specified, is ignored (ANS85) and control is transferred to the end of the STRING statement or, if the ON OVERFLOW phrase is specified, to imperative- statement-1. If control is transferred to imperative- statement-1, execution continues according to the rules for each statement specified in imperative-statement-1. If a procedure branching or conditional statement which causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement; otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the STRING statement. ________________________________________________________________________ |(ANS85) | | | | | | | |10. If, at the time of execution of a STRING statement with the NOT | | ON OVERFLOW phrase, the conditions described in General Rule 9 | | are not encountered, after completion of the transfer of data | | according to the other general rules, the ON OVERFLOW phrase, if | | specified, is ignored and control is transferred to the end of | | the STRING statement or, if the NOT ON OVERFLOW phrase | | is specified, to imperative- statement-2. If control is | | transferred to imperative- statement-2, execution continues | | according to the rules for each statement specified in | | imperative-statement-2. If a procedure branching or conditional | | statement which causes explicit transfer of control is executed, | | control is transferred in accordance with the rules for that | | statement; otherwise, upon completion of the execution of | | imperative-statement-2, control is transferred to the end of the | | STRING statement. | | | |11. The END-STRING phrase delimits the scope of the STRING statement.| | (See the section "Explicit and Implicit Scope Terminators" in| | the chapter COBOL Concepts.) | | | ________________________________________________________________________ The SUBTRACT Statement Function The SUBTRACT statement is used to subtract one, or the sum of two or more, numeric data items from one or more items, and set the values of one or more items equal to the results. General Formats Format 1
[]
Format 2
[]
Format 3
[]
Syntax Rules 1. Each identifier must refer to a numeric elementary item, except that in Format 2 each identifier following the word GIVING must refer to either an elementary numeric item or an elementary numeric edited item, and in Format 3 each identifier must refer to a group item. 2. Each literal must be a numeric literal. 3. The composite of operands must not contain more than 18 digits. (See the section "Arithmetic Statements" earlier in this chapter.) a. In Format 1 the composite of operands is determined by using all of the operands in a given statement. b. In Format 2 the composite of operands is determined by using all of the operands in a given statement excluding the data items that follow the word GIVING. c. In Format 3 the composite operands is determined separately for each pair of corresponding data items. 4. CORR is an abbreviation for CORRESPONDING. ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |5. Floating-point data items and literals can be used anywhere | | numeric data items and literals can be specified. | | | ________________________________________________________________________ General Rules 1. See the sections "The ROUNDED Phrase" , " The ON SIZE ERROR Phraseand NOT ON SIZE ERROR Phrase (ANS85)" , "Arithmetic Statements" , "Overlapping Operands" and "Multiple Results in Arithmetic Statements" in this chapter. 2. In Format 1, all literals or identifiers preceding the word FROM are added together and this total is subtracted from the current value of identifier-2 storing the result immediately into identifier-2, and repeating this process respectively for each operand following the word FROM. 3. In Format 2, all literals or identifiers preceding the word FROM are added together, the sum is subtracted from literal-2 or identifier-2 and the result of the subtraction is stored as the new value of each data item referenced by identifier-3. 4. If Format 3 is used, data items in identifier-1 are subtracted from and stored into corresponding data items in identifier-2. ________________________________________________________________________ |(MF) (VSC2) | | | | | | | |5. The COBOL system ensures enough places are carried so as not to | | lose significant digits during execution. | | | ________________________________________________________________________ ________________________________________________________________________ |The TRANSFORM Statement | | | |(OSVS) | | | |Function | | | |The TRANSFORM statement is used to alter characters according to a | |transformation rule. | ________________________________________________________________________ General Format
[]
________________________________________________________________________ |(OSVS) | | | |Syntax Rules | | | | | | 1. Identifier-3 can be any elementary item except a numeric item | | with USAGE other than DISPLAY, or a group item. | | | | 2. Identifier-1 and identifier-2 should be elementary alphabetic | | or alphanumeric items. | | | | 3. Nonnumeric-literal-2 or identifier-2 must be either one | | character long or the same length as nonnumeric-literal-1 or | | identifier-1. | | | |General Rules | | | | | | 1. The use of figurative-constant-1 and/or figurative-constant-2 | | is equivalent to the use of a single-character nonnumeric- | | literal with the same value. | | | | 2. If either identifier-1 or identifier-2 references the same | | computer storage area as identifier-3, the result of the | | TRANSFORM is undefined. (See the section "The REDEFINES | | Clause" earlier in this chapter.) | | | | 3. If characters are repeated in nonnumeric-literal-1 or | | identifier-1, then the result of the TRANSFORM operation is | | undefined. | | | | 4. Execution of the TRANSFORM statement scans identifier-3 for | | occurrences of individual characters from identifier-1 | | or nonnumeric-literal-1. When a match is found, the | | corresponding character (or the single character of a | | one-character field) from identifier-2 or nonnumeric-literal-2 | | is substituted into that character position in identifier-3. | | The correspondence between identifier-1 or nonnumeric- | | literal-1 and identifier-2 or nonnumeric-literal-2 is by | | occurrence number of the character within the data item | | (starting from the left). | ________________________________________________________________________ The UNSTRING Statement Function The UNSTRING statement causes contiguous data in a sending field to be separated and placed into multiple receiving fields. General Format
[]
Syntax Rules 1. Each literal must be a nonnumeric literal. In addition, each literal can be any figurative constant without the optional word ALL. 2. Identifier-1, identifier-2, identifier-3, and identifier-5 must be described, implicitly or explicitly, as an alphanumeric data- item. 3. Identifier-4 can be described as either alphabetic (except that the symbol "B" can not be used in the PICTURE character-string), alphanumeric, or numeric (except that the symbol "P" can not be used in the PICTURE character-string), and must be described as USAGE IS DISPLAY. ________________________________________________________________________ |(MF) | | | | | | | |4. Syntax Rules 2 and 3 do not apply. Instead, the following rules | | apply: | | | | | | * Identifier-1 must be alphanumeric | | | | * Identifier-2 and identifier-3 must be USAGE DISPLAY and | | must not be edited | | | | * Identifier-4 and identifier-5 must be USAGE DISPLAY | | | | * Identifier-4 can have any USAGE if it is defined | | as numeric and the data results in a valid move | | operation | | | ________________________________________________________________________ ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |5. Identifier-4 must not be defined as a floating-point item. | | | ________________________________________________________________________ 6. Identifier-6 and identifier-8 must reference integer data items, (except that the symbol "P" can not be used in the PICTURE character-string). 7. Identifier-1 must be described as an elementary numeric integer data item of sufficient size to contain a value equal to 1 plus the size of the data item referenced by identifier-1. The symbol "P" can not be used in the PICTURE character string of identifier-7. 8. No identifier can name a level 88 entry. 9. The DELIMITER IN phrase and the COUNT IN phrase can be specified only if the DELIMITED BY phrase is specified. General Rules 1. All references to identifier-2, literal-1, apply equally to identifier-3, literal-2, respectively and all recursions thereof. 2. Identifier-1 represents the sending area. 3. Identifier-4 represents the data receiving area. Identifier-5 represents the receiving area for delimiters. 4. Literal-1 or the data item referenced by identifier-2 specifies a delimiter. 5. The data item referenced by identifier-6 represents the count of the number of characters within the data item referenced by identifier-1 isolated by the delimiters for the move to the data item referenced by identifier-4. This value does not include a count of the delimiter character(s). 6. The data item referenced by identifier-7 contains a value that indicates a relative character position within the area defined by identifier-1. 7. The data item referenced by identifier-8 is a counter that records the number of data items acted upon during the execution of an UNSTRING statement. 8. When a figurative constant is used as the delimiter, it stands for a single character nonnumeric literal. When the ALL phrase is specified, one occurrence or two or more contiguous occurrences of literal-1 (figurative constant or not) or the contents of the data item referenced by identifier-2 are treated as if it were only one occurrence, and this occurrence is moved to the receiving data item according to the rules in General Rule 13d. 9. When any examination encounters two contiguous delimiters, the current receiving area is either space or zero filled according to the description of the receiving area. 10. Literal-1 or the contents of the data item referenced by identifier-2 can contain any character in the computer's character set. 11. Each literal-1 or the data item referenced by identifier-2 represents one delimiter. When a delimiter contains two or more characters, all of the characters must be present in contiguous positions of the sending item and in the order given, to be recognized as a delimiter. 12. When two or more delimiters are specified in the DELIMITED BY phrase, an "OR" condition exists between them. Each delimiter is compared to the sending field. If a match occurs, the character(s) in the sending field is considered to be a single delimiter. No character(s) in the sending field can be considered a part of more than one delimiter. Each delimiter is applied to the sending field in the sequence specified in the UNSTRING statement. 13. When the UNSTRING statement is initiated, the current receiving area is the data item referenced by identifier-4. Data transferred from the data item referenced by identifier-1 to the data item referenced by identifier-4 according to the following rules: a. If the POINTER phrase is specified, the string of characters referenced by identifier-1 is examined beginning with the relative character position indicated by the contents of the data item referenced by identifier-7. If the POINTER phrase is not specified, the string of characters is examined beginning with the leftmost character position. b. If the DELIMITED BY phrase is specified, the examination proceeds left to right until either a delimiter specified by the value of literal-1 or the data item referenced by identifier-2 is encountered. (See General Rule 11.) If the DELIMITED BY phrase is not specified, the number of characters examined is equal to the size of the current receiving area. However, if the sign of the receiving item is defined as occupying a separate character position, the number of characters examined is one less than the size of the current receiving area. If the end of the data item referenced by identifier-1 is encountered before the delimiting condition is met, the examination terminates with the last character examined. c. The characters thus examined (excluding the delimiting character(s), if any) are treated as an elementary alphanumeric data item, and are moved into the current receiving area according to the rules for the MOVE statement. (See the section "The MOVE Statement" earlier in this chapter.) d. If the DELIMITER IN phrase is specified, the delimiting character(s) are treated as an elementary alphanumeric data item and are moved into the data item referenced by identifier-5 according to the rules for the MOVE statement. (See the section "The MOVE Statement" earlier in this chapter.) If the delimiting condition is the end of the data item referenced by identifier-1, then the data item referenced by identifier-5 is space-filled. e. If the COUNT IN phrase is specified, a value equal to the number of characters thus examined (excluding the delimiter character(s) if any) is moved into the area referenced by identifier-6 according to the rules for an elementary move. f. If the DELIMITED BY phrase is specified the string of characters is further examined beginning with the first character to the right of the delimiter. If the DELIMITED BY phrase is not specified, the string of characters is further examined beginning with the character to the right of the last character transferred. g. After data is transferred to the data item referenced by identifier-4, the current receiving area is the data item referenced by the next recurrence of identifier-4. The behavior described in paragraph 13b. through 13f. is repeated until either all the characters are exhausted in the data item referenced by identifier-1, or until there are no more receiving areas. 14. The initialization of the contents of the data items associated with the POINTER phrase or the TALLYING phrase is the responsibility of the user. 15. The contents of the data item referenced by identifier-7 will be incremented by one for each character examined in the data item referenced by identifier-1. When the execution of an UNSTRING statement with a POINTER phrase is complete, the contents of the data item referenced by identifier-7 will contain a value equal to the initial value plus the number of characters examined in the data item referenced by identifier-1. 16. When the execution of an UNSTRING statement with a TALLYING phrase is completed, the contents of the data item referenced by identifier-8 contains a value equal to its initial value plus the number of data receiving items acted upon. 17. Either of the following situations causes an overflow condition: a. An UNSTRING is initiated, and the value in the data item referenced by identifier-7 is less than 1 or greater than the size of the data item referenced by identifier-1. b. If, during execution of an UNSTRING statement, all data receiving areas have been acted upon, and the data item referenced by identifier-1 contains characters that have not been examined. 18. When an overflow condition exists, the UNSTRING operation is terminated, the NOT ON OVERFLOW phrase, if specified, is ignored and (ANS85) control is transferred to the end of the UNSTRING statement or, if the ON OVERFLOW phrase is specified, to imperative-statement-1. If control is transferred to imperative-statement-1, execution continues according to the rules for each statement specified in imperative-statement-1. If a procedure branching or conditional statement which causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement; otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the UNSTRING statement. ________________________________________________________________________ |(ANS85) | | | | | | | |19. The END-UNSTRING phrase delimits the scope of the UNSTRING | | statement. (See the section "Explicit and Implicit Scope | | Terminators" in the chapter COBOL Concepts.) | | | ________________________________________________________________________ 20. If, at the time of execution of an UNSTRING statement, the conditions described in General Rule 17 are not encountered, after completion of the transfer of data according to the other general rules, the ON OVERFLOW phrase, if specified, is ignored and control is transferred to the end of the UNSTRING statement ________________________________________________________________________ |(ANS85) | |or, if the NOT ON OVERFLOW phrase is specified, to | |imperative-statement-2. If control is transferred to imperative- | |statement-2, execution continues according to the rules for each | |statement specified in imperative-statement-2. If a procedure | |branching or conditional statement which causes explicit transfer of | |control is executed, control is transferred in accordance with the | |rules for that statement; otherwise, upon completion of the execution | |of imperative-statement-2, control is transferred to the end of the | |UNSTRING statement. | ________________________________________________________________________ 21. The evaluation of subscription and indexing for the identifiers is as follows: a. Any subscripting or indexing associated with identifier-1, identifier-7, identifier-8 is evaluated only once, immediately before any data is transferred as the result of the execution of the UNSTRING statement. b. Any subscripting or indexing associated with identifier-2, identifier-3, identifier-4, identifier-5, identifier-6 is evaluated immediately before the transfer of data into the respective data item. ________________________________________________________________________ |(ANS85) | | | | | | | |22. Any subscripting associated with the DELIMITED BY identifier, the| | INTO identifier, the DELIMITER IN identifier, or the COUNT IN | | identifier is evaluated once, immediately before the examination | | of the sending fields for the delimiter. | | | ________________________________________________________________________ 23. If identifier-1, identifier-2 or identifier-3, occupies the same storage area as identifier-4, identifier-5 , identifier-6 , identifier-7 or identifier-8, or if identifier-4, identifier-5 or identifier-6, occupies the same storage area as identifier-7 or identifier-8, or if identifier-7 and identifier-8 occupy the same storage area, the result of the execution of this statement is undefined, even if they are defined by the same data description entry. ________________________________________________________________________ |The USE Statement | | | |(ANS85) | | | |Function | | | |The USE statement determines whether the associated declarative | |procedures are invoked during the execution of any program contained | |within the program which includes the USE statement. | | | |The BEFORE REPORTING format determines whether the associated | |declarative procedures are invoked during the execution of any program| |contained within the program which includes the USE BEFORE REPORTING | |statement. | ________________________________________________________________________ General Formats Format 1
[]
________________________________________________________________________ |(ANS85) | | | |Format 2 | | | | USE [GLOBAL] BEFORE REPORTING identifier-1 | | | |Syntax Rules | | | |Format 1 | | | |See Chapter 5 , File Input And Output . | | | |General Rule | | | |Special precedence rules are followed when programs are contained | |within other programs. In applying these rules, only the first | |qualifying declarative will be selected for execution. The | |declarative which is selected for execution must satisfy the rules for| |execution of that declarative. The order of precedence for selecting | |a declarative is: | | | | | | a. The declarative within the program that contains the statement | | which caused the qualifying condition. | | | | b. The declarative in which the GLOBAL phrase is specified and | | which is within the program directly containing the program | | which was last examined for a qualifying declarative. | | | | c. Any declarative selected by applying rule 1b. to each more | | inclusive containing program until rule 1b. is applied to the | | outermost program. If no qualifying declarative is found, none| | is executed. | ________________________________________________________________________


MPE/iX 5.0 Documentation