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 ACCEPT Statement (Continued) 

General Rules.   

All Formats.   

   1.  The END-ACCEPT phrase delimits the scope of the ACCEPT statement.
       (See the section Explicit And Implicit Scope Terminators in the
       chapter Concepts of the COBOL Language.)  END-ACCEPT is treated as
       a reserved word only if the MF(4) system directive is set.  See
       your COBOL System Reference for details.

Format 1.   

2.      The ACCEPT statement causes the transfer of data from the logical
        or physical device.  This data replaces the content of the data
        item referenced by identifier.  If the data item referenced by
        identifier has an explicit or implicit usage of DISPLAY then
        replacement is direct and without conversion, otherwise
        conversion into the correct format takes place.

        The size of a data transfer is determined by the device and the
        run-time environment (see The SPECIAL-NAMES Paragraph for a list
        of function-names that can be used and your COBOL System 
        Referencefor details of devices and the limits of data transfer
        sizes).

        If the device is capable of transferring data of the same size as
        the receiving data item, the transferred data is stored in the
        receiving data item.  If otherwise, then:

           a.  If the size of the receiving data item (or the portion not
               yet currently occupied by transferred data) exceeds the
               size of the transferred data, the transferred data is
               stored aligned to the left in the receiving data item (or
               the portion not yet occupied) and additional data is
               requested.

           b.  If the size of the transferred data exceeds the size of
               the receiving data item (or portion not yet occupied by
               transferred data), only the leftmost characters of the
               transferred data are stored in the receiving data item (or
               in the portion remaining).  The remaining characters of
               the transferred data which do not fit into the receiving
               data item are ignored.

               If the FROM option is not given, it is equivalent to
               specifying FROM CONSOLE.

3.      For MF and XOPEN only:    If the function-name COMMAND-LINE, or a
        mnemonic-name associated with the function-name COMMAND-LINE, is
        specified, the contents of a system-dependent command-line buffer
        are transferred to the receiving data item.

4.      For MF and XOPEN only:    If the mnemonic-name associated with
        the function-name ARGUMENT-NUMBER is used, identifier receives
        the number of arguments contained in the command line.  (This
        includes all arguments, those before the program-name, the
        program-name itself, and any arguments following the
        program-name.  Hence no portability from types of program
        invocation is expected.)

5.      For MF and XOPEN only:    When mnemonic-name is associated with
        ARGUMENT-VALUE, the current command-line argument is placed into
        identifier.  The determination of which command-line argument is
        current is as follows:

           a.  Initially, the first command-line argument is current.

           b.  A DISPLAY upon a mnemonic-name associated with
               ARGUMENT-NUMBER sets the current command-line argument
               number to the value of the identifier or literal specified
               in the DISPLAY statement.

           c.  When an ACCEPT statement from a mnemonic-name associated
               with ARGUMENT-NUMBER has been executed since the last
               execution of a DISPLAY statement upon a mnemonic-name
               associated with ARGUMENT-NUMBER, the current command-line
               argument number is incremented prior to its use in this
               ACCEPT statement.

        If the current command-line argument number is 0, it is intended
        that the program-name of the main program of the run unit will be
        returned.  However, the effects of variations on program
        invocation can impact these results so that a utility or calling
        program can be returned instead.  (See your COBOL System 
        Reference for additional details.)

        If the current command-line argument number  is not in the range 
        0 to 99 inclusive or  (XOPEN only) exceeds the number of
        arguments on the command line when this ACCEPT statement is
        executed, imperative-statement-1, if specified, will be executed.

6.      For MF and XOPEN only:    If the mnemonic-name associated with
        the function-name ENVIRONMENT-VALUE is used then,

           a.  If a previous DISPLAY with a mnemonic-name associated with
               an ENVIRONMENT-NAME has been performed, the value of the
               designated environment-variable is placed into identifier.

           b.  If no previous DISPLAY with a mnemonic-name associated
               with an ENVIRONMENT-NAME has been performed, or if the
               specified environment-variable does not exist, the
               imperative statement associated with an ON EXCEPTION
               phrase is executed.  The value in identifier is undefined
               in this case.

7.      The effect of retrieving command line arguments and the number of
        arguments in a program that is called by another program is
        defined as the same as if they were retrieved by the first
        program in the run unit.

Format 2.   

8.      The ACCEPT statement causes the information requested to be
        transferred to the data item specified by identifier according to
        the rules of the MOVE statement.  DATE, DAY ,DAY-OF-WEEK (ANS85
        only) and TIME are conceptual data items and, therefore, are not
        described in the COBOL program.

9.      DATE is composed of the data elements:  year of century, month of
        year, and day of month.  The sequence of the data element codes
        shall be from high to low order (left to right):  year of
        century, month of year, and day of month.  DATE, when accessed by
        a COBOL program, behaves as if it had been described in the COBOL
        program as an unsigned elementary numeric integer data item six
        digits in length.

10.     DAY is composed of the data elements:  year of century and day of
        year.  The sequence of the data element codes shall be from high
        order to low order (left to right):  year of century, day of
        year.  Therefore, July 1, 1968 would be expressed as 68183.  DAY,
        when accessed by a COBOL program, behaves as if it had been
        described in a COBOL program as an unsigned elementary numeric
        integer data item five digits in length.

11.     For ANS85 only:  DAY-OF-WEEK is composed of a single data element
        whose content represents the day of the week.  DAY-OF-WEEK, when
        accessed by a COBOL program, behaves as if it had been described
        in a COBOL program as an unsigned elementary numeric integer data
        item one digit in length.  In DAY-OF-WEEK, the value 1 represents
        Monday, 2 represents Tuesday,..., 7 represents Sunday.

12.     TIME is composed of the data elements:  hours, minutes, seconds
        and hundredths of a second.  TIME is based on elapsed time after
        midnight on a 24-hour clock basis - thus, 2:41 P.M. would be
        expressed as 14410000.  TIME, when accessed by a COBOL program
        behaves as if it had been described in a COBOL program as an
        unsigned elementary numeric integer data item eight digits in
        length.  The minimum value of TIME is 00000000; the maximum value
        of TIME is 23595999.  If the hardware does not have the facility
        to provide fractional parts of TIME, the value is converted to
        the closest decimal approximation.

For MF only:  Format 3.   

13.     The value returned from the ACCEPT FROM LINE NUMBER phrase is
        always numeric.  The value is implementation- dependent.  See
        your COBOL System Reference for details.

14.     The FROM USER NAME option returns a user-id number on UNIX
        systems, or spaces on systems where such a concept is
        meaningless.

15.     The FROM ESCAPE KEY option returns the two digit code generated
        by a termination key.

16.     The EXCEPTION STATUS item contains a three-digit numeric value
        that identifies the type of exception condition that has occurred
        during the execution of a CALL statement.

        If EXCEPTION STATUS is to be examined this should be done
        immediately following the CALL statement.  There must be nothing
        between the CALL and ACCEPT FROM EXCEPTION STATUS. File I-O
        operations will alter the exception status value making it
        unpredictable.

For MF only:  Format 4.   

17.     This format of the ACCEPT statement accepts screen items,which
        are defined in the Screen Section of the program, and allows full
        access to the enhanced screen handling facilities.

For MF only:  Formats 4 and 5.   

18.     The order of execution of an ACCEPT statement is always:

           a.  the AT phrase

           b.  the BLANK phrase

           c.  display of current contents of the data area

           d.  the BELL phrase

           e.  the ACCEPT operation.

19.     The AT phrase gives the absolute address on the screen where the
        ACCEPT operation is to start.

20.     If integer-3 or identifier-4 is 4 digits long, the first two
        digits specify the line, the second two the column.  If 6 digits
        long, the first three digits specify the line, while the second
        three specify the column.

21.     Certain combinations of line and column numbers have special
        meanings, as follows:

           a.  Until the column comes within range, out of range column
               values are reduced by the line length and the line value
               is incremented.

           b.  Out of range line values cause the screen to scroll up one
               line.  The effect is the same as if the line number of the
               bottom line had been specified.

           c.  If the line and column numbers given are both zero, the
               ACCEPT starts at the position following that where the
               preceding Format 4 or Format 5 ACCEPT operation finished.
               Column 1 of each line is considered to follow the last
               column of the previous line.

           d.  If the line number is zero, but a non-zero column number
               is specified, the ACCEPT starts at the specified column,
               on the line following that where the preceding Format 4 or
               Format 5 ACCEPT operation finished.

           e.  If the column number is zero, but a non-zero line number
               is specified, the ACCEPT starts on the specified line, at
               the column following that where the preceding Format 4 or
               Format 5 ACCEPT operation finished.

22.     If the ON EXCEPTION phrase is specified, imperative-statement-1
        is executed if the ACCEPT operation finishes with anything other
        than a normal termination.  If the NOT ON EXCEPTION phrase is
        specified, imperative-statement-2 is executed if the ACCEPT
        operation terminates normally.  (See the section The CRT STATUS 
        Clause earlier in this chapter for possible types of
        termination.)

For MF only:  Format 5.   

23.     The ACCEPT operation starts at line 1, column 1 if no AT phrase
        is specified.

24.     If identifier is a group item and no MODE IS BLOCK phrase exists,
        then those elementary subordinate items which have names other
        than FILLER are accepted.  They are positioned on the screen in
        the order their descriptions appear in the Data Division and are
        separated by the lengths of the FILLER items in the group.  For
        this purpose, the first position on a line is regarded as
        immediately following the last position on the previous line.
        The items are accepted in the same order.

        Unless otherwise specified in the CURSOR IS clause (see the
        section The CURSOR IS Clause earlier in this chapter), the cursor
        is initially positioned at the start of the first item.  As the
        ACCEPT operation into each item is terminated, the cursor moves
        to the start of the next item.

25.     The MODE IS BLOCK phrase indicates that the identifier is to be
        treated as an elementary item.  Thus, even if it is a group item
        it is displayed as one item.

26.     If the PROMPT option is not specified, no character is output to
        mark empty character-positions.  PROMPT without the CHARACTER
        option causes this to be done, using the character configured for
        this purpose.

27.     If the PROMPT option is not specified, those character-positions
        into which the operator does not enter data produce spaces in the
        data item.

28.     The WITH phrase allows you to specify certain options available
        during the operation.  (See The Screen Section earlier in this
        chapter for descriptions of these clauses.)

        In addition to the options available as screen description
        clauses, the following options can be used in the WITH phrase;
        SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY TRAILING-SIGN
        and UPDATE. ZERO-FILL appears in this list and as a screen
        description clause because it has two different uses.  Its second
        use is documented later in this chapter.

        A configuration option is available which allows the entry of
        data into numeric and numeric edited screen fields in free format
        mode.  In COBOL, nonedited numeric data items are intended for
        holding data in an internal form; however, this format enables
        such data items to appear on the screen.  See your COBOL System
        Reference for more details.  If free format mode is in effect,
        the data will appear automatically reformatted as follows:

           *   with the virtual decimal point represented by a period

           *   with the sign represented by a sign character ("-" for
               minus; space for plus) which appears immediately before
               the leftmost digit

           *   with zero suppression in all integer character positions,
               except the least significant

           *   with left justification.

        The SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY and
        TRAILING-SIGN options amend this format.

29.     The SPACE-FILL option causes data in free format nonedited
        numeric data items to appear on the screen with zero-suppression
        in all integer character positions.  This option affects only
        free format, nonedited numeric data items.  This takes effect
        when initial data in the data item is displayed and again when
        the ACCEPT operation into the data item is terminated.  Any
        leading sign is displayed in the rightmost space.

30.     The ZERO-FILL option causes data in free format nonedited numeric
        data items to appear on the screen with no zero-suppression.
        This takes effect when initial data in the data item is displayed
        and again when the ACCEPT operation into the data item is
        terminated.  (See the section The ZERO-FILL Clause earlier in
        this chapter for this option's effect when used with alphabetic
        or alphanumeric data items.)

31.     The LEFT-JUSTIFY option is documentary only.

32.     The RIGHT-JUSTIFY option causes operator-keyed characters to be
        moved on the screen to the rightmost character positions of the
        field.  This option affects only free format nonedited numeric
        data items.  This takes effect upon display of the initial data
        (the current contents displayed) in the data item and also upon
        termination of the ACCEPT operation.

33.     The TRAILING-SIGN option causes the operational sign to appear in
        the rightmost character position of the field.  This takes effect
        upon display of initial data in the data item and also upon
        termination of the ACCEPT operation.  This option affects only
        signed, nonedited numeric data items which are in free format
        mode.

34.     The UPDATE option causes the current contents (initial data) of
        the data item to be displayed before the operator is prompted to
        key in new input.  If the operator does not key in any new
        data, the initial data is then treated as though it were
        operator-keyed.  If the UPDATE option is not specified, the
        display of initial data is a configuration option.  (See your
        COBOL System Reference for details of configuration options.)

35.     The WITH UPPER option forces input into upper case.

36.     The WITH LOWER option forces input into lower case.

37.     If REDEFINES is used with identifier-1, the first description of
        the redefined data area is used and subsequent descriptions are
        ignored.  If OCCURS or nested OCCURS are used the repeated data
        item is expanded into the full number of times it occurs, so that
        one definition is repeated for many fields.

38.     If identifier-8 or integer-7 has a negative value, this
        represents a request that no time-out "exception" should occur no
        matter how long there is between/before key-strokes.

39.     If identifier-8 or integer-7 is zero, this indicates that a
        time-out should not occur if characters are waiting.  However, if
        no characters are waiting (when the ACCEPT is processed), then
        issue a time-out immediately.

40.     The ON EXCEPTION clause, if present, will be executed when a
        time-out occurs and a TIME-OUT clause is specified.  The NOT ON
        EXCEPTION clause, if present, will be executed when a TIME-OUT
        clause is specified but no time-out (or other exception) occurs.

41.     If a time-out exception occurs, then the contents of any ACCEPT
        resultant-field will be defined as follows:

           a.  Any field which has been partially modified will contain
               any information which has already been received.

           b.  Fields which have "FULL" or "REQUIRED" attributes or any
               other attribute which would normally impact partial field
               input, will NOT be required to meet those attributes when
               a partial field entry has occurred when a time-out
               exception occurs.

           c.  The rules listed above apply whether or not the timeout
               clock is reset upon each keystroke.

42.     If at run time a positive timeout interval greater than
        2,147,483,647 hundredths of a second is detected the timeout
        value will be reset to 2,147,483,647 hundredths of a second
        (which is approximately eight months).

43.     The TIME-OUT value specifies the number of seconds (or tenths of
        a second) after the ACCEPT statement begins processing until a
        time-out exception occurs.  A new ADISCF configuration option
        controls whether or not the timeout clock is "reset" each time a
        new keyboard action is detected.  An application which wants some
        ACCEPT statements to be handled with a RESET and some without,
        can make specific calls to the ADIS run-time interface before or
        after the ACCEPT statements that need changes from the default.
        For example when ADIS was configured not to do resets, if a
        program had:

             ACCEPT INPUT-FIELD TIME-OUT AFTER +10

        a timeout would occur after 10 seconds had elapsed from the
        beginning of the ACCEPT, even if some characters were entered
        after 5 seconds into the ACCEPT processing.

        If, on the other hand, ADIS were configured to do resets, if a
        program had the same code given above, then each time a new
        character were entered, the TIMEOUT "clock" would be reset to
        zero.

44.     If a timeout exception occurs and no ON EXCEPTION phrase is
        specified, the CRT Status keys (if specified) are updated, the
        application continues to the next logical phrase, and the
        contents of the ACCEPT receiving field are as defined above.
        (The above is true whether or not a NOT ON EXCEPTION phrase is
        specified.)

45.     All references to (NOT) ON EXCEPTION phrases also apply to (NOT)
        ON ESCAPE phrases.

Format 1 and 5.   

46.     For alphanumeric data items, the size of the field that is
        accepted from the screen during an ACCEPT statement is exactly
        the same size as the target field.  Therefore, if you want data
        to appear at the right hand side of a field, you must enter it
        there.

The ADD Statement 

Function.   

The ADD statement causes two or more numeric operands to be summed and
the result to be stored.

General Formats.   

Format 1.   

[]
Format 2.
[]
Format 3.
[]
Syntax Rules. All Formats. 1. In Formats 1 and 2, each identifier must refer to an elementary numeric 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. 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 of operands is determined separately for each corresponding pair of data items. 4. In Format 3, CORR is an abbreviation for CORRESPONDING. 5. For OSVS, VSC2, and MF only: Floating-point literals and floating-point data items can be used anywhere a numeric data item or literal can be specified. General Rules. All Formats. 1. See the section The ROUNDED Phrase, The ON SIZE ERROR Phrase, The CORRESPONDING Phrase, Arithmetic Statements, Overlapping Operands and Multiple Results In Arithmetic Statements in this chapter; the section Explicit And Implicit Scope Terminators in the chapter Concepts of the COBOL Language, and the section Delimited Scope Statements in the chapter Concepts of a COBOL Program. 2. If Format 1 is used, the values of the operands preceding the word TO are added together, then this sum is added to the current value of identifier-2 storing the result immediately into identifier-2, and repeating this process respectively for each successive operand following the word TO in left-to-right order. 3. If Format 2 is used, the value of the operands preceding the word GIVING are added together, then the sum is stored as the new value of each data item referenced by identifier-3, the resultant identifier. 4. If Format 3 is used, data items in identifier-1 are added to and stored in corresponding data items in identifier-2. 5. For MF only: Your COBOL system ensures that enough places are carried so as not to lose any significant digits during execution. The ALTER Statement Function. The ALTER statement modifies a predetermined sequence of operations. For ANS85 only: The ALTER 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 in 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, this verb is explicitly excluded from the X/Open COBOL language definitions and should not be used in a conforming X/Open COBOL source program . General Format.
[]
Syntax Rules. 1. Each procedure-name-1, procedure-name-3,..., is the name of a paragraph that contains a single sentence consisting of a GO TO statement without the DEPENDING phrase. 2. Each procedure-name-2, procedure-name-4,..., is the name of a paragraph or section in the Procedure Division. General Rules. 1. Execution of the ALTER statement modifies the GO TO statement in the paragraph named procedure-name-1, procedure-name-3,..., so that subsequent executions of the modified GO TO statements cause transfer of control to procedure-name-2, procedure-name-4,..., respectively. Modified GO TO statements in independent segments can, under some circumstances, be returned to their initial states (see the section Independent Segments in the chapter Segmentation in your Language Reference - Additional Topics). 2. A GO TO statement in a section whose segment-number is greater than or equal to 50 must not be referred to by an ALTER statement in a section with a different segment- number. All other uses of the ALTER statement are valid and are performed even if procedure-name-1, procedure-name-3 is in an overlayable fixed segment.


MPE/iX 5.0 Documentation