HP 3000 Manuals

General Formats (Continued) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation


Micro Focus COBOL Language Reference

General Formats (Continued) 

The STOP Statement 

Function.   

The STOP statement causes a permanent or temporary suspension of the
execution of the object program.

For ANS85 only:  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.

For MF only:    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.

For XOPEN only:  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.   

[]
Format 2.
[]
Syntax Rules. Format 1. 1. Literal-1 must not be a figurative constant that begins with the word ALL. 2. If literal-1 is numeric, then it must be an unsigned integer. For OSVS and VSC2 only: A signed integer is allowed. 3. For MF only: Integer-1 may be signed. Formats 1 and 2. 4. 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. For OSVS, VSC2, and MF only: 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. 5. For MF only: GIVING and RETURNING are equivalent. 6. For MF only: Identifier-1 must be no larger than 8 bytes in size. General Rules. 1. If the RUN phrase is specified, execution of the run unit ceases and control is transferred to the operating system. 2. During the execution of a STOP RUN statement, an implicit CLOSE statement without any optional phrases is executed for each file that is in the open mode in the run unit. Any USE procedures associated with any of these files are not executed. 3. If the run unit has been accessing messages, the STOP RUN statement causes the message control system (MCS) to eliminate form the queue any message partially received by that unit. Any portion of a message transferred from the run unit via a send statement, but not terminated by an EMI or EGI, is purged from the system. 4. For MF only: Execution of a STOP RUN statement causes a return value to be set in the system area generally available for non-COBOL programs to return a value. If the operating system supports the facility of returning a value from a program that is run to the operating system environment (see your COBOL System Reference for details) then it will return the value from the system area. If the GIVING phrase is not specified then the object program operates as if the system area were declared as a COBOL numeric data item with USAGE COMP-5 and with a size determined by the operating environment external to the COBOL system (see your COBOL System Reference) and as if a MOVE statement had been executed with the RETURN-CODE as the sending item and the system area as the receiving item. (See the section Special Registers in the chapter Concepts of the COBOL Language for details of RETURN-CODE.) If the GIVING identifier-1 phrase is specified, identifier-1 must describe the same number of character positions as is required to hold the return value in the system area and must be of the type and usage that is expected by the operating system. Typically identifier-1 will need to be declared with an explicit or implicit PICS9 (9) USAGE COMP-5. The object program operates as if a MOVE statement had been executed with identifier-1 as the sending item and the system area as the receiving item. IF the GIVING integer-1 phrase is specified, integer-1 must not be larger than the value that can be held in the system area. The object program operates as if a MOVE statement had been executed with integer-1 as the sending item and the system area as the receiving item. 5. If STOP literal-1 is specified, the execution of the run unit is suspended and literal-1 is communicated to the operator. Continuation of the execution of the run unit begins with the next executable statement when the operator presses the ENTER key or its equivalent. 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. 6. For ANS85 only: Identifier-3 must not be reference . 7. For MF only: Identifier-3 can 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 only) 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. 10. For ANS85 only: 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. For ANS85 only: The END-STRING phrase delimits the scope of the STRING statement. (See the section Explicit And Implicit Scope Terminators in the chapter Concepts of the COBOL Language.) 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. All Formats. 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. The composite of operands must not contain more than 18 digits. (See the section The 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. Formats 1 and 2. 3. Each literal must be a numeric literal. 4. For OSVS, VSC2 and MF only: Floating-point data items and literals can be used anywhere numeric data items and literals can be specified. Format 3. 5. CORR is an abbreviation for CORRESPONDING. General Rules. All Formats. 1. See the sections The ROUNDED Phrase, The ON SIZE ERROR Phrase, Arithmetic Statements, Overlapping Operands and Multiple Results In Arithmetic Statements in this chapter. 2. For MF and VSC2 only: The COBOL system ensures enough places are carried so as not to lose significan digits during execution. Format 1. 3. 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. Format 2. 4. 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. Format 3. 5. If Format 3 is used, data items in identifier-1 are subtracted from and stored into corresponding data items in identifier-2. For OSVS only: The TRANSFORM Statement Function. The TRANSFORM statement is used to alter characters according to a transformation rule. General Format.
[]
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). For MF only: The UNLOCK Statement Function. The UNLOCK statement releases all record locks held by the run unit on a named file. General Format.
[]
Syntax Rule. File-name must occur in the SELECT statement of the FILE CONTROL entry. General Rules. 1. The file referenced by file-name must already be opened with the OPEN statement. 2. The UNLOCK statement releases all record locks held by the run unit on a named file. 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. 4. For MF only: 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-5 must be USAGE DISPLAY * Identifier-4 can be USAGE DISPLAY * Identifier-4 can have any USAGE that defines a numeric data item as long as the data results in a valid MOVE operation. 5. For VSC2, OSVS, and MF only: 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. 10. For MF only: The source of an UNSTRING operation can be reference modified . 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 only) 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. 19. For ANS85 only: The END-UNSTRING phrase delimits the scope of the UNSTRING statement. (See the section Explicit And Implicit Scope Terminators in the chapter Concepts of the COBOL Language.) 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 For ANS85 only: 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, or 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, -3, -4, -5, or -6 is evaluated immediately before the transfer of data into the respective data item. 22. For ANS85 only: 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, -2 or -3, occupies the same storage area as identifier-4, -5, -6, -7 or -8, or if identifier-4, -5 or -6 , occupies the same storage area as identifier-7 or -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.


MPE/iX 5.0 Documentation