[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

Formats 6, 7, and 8

  1. When a Format 6 ACCEPT statement is specified, the value of arg-count is moved to dest-item. This represents the number of arguments on the program run command line (see ARGUMENT-NUMBER in the SPECIAL-NAMES paragraph in Chapter 4).
  2. When the current argument position indicator is zero, it refers to the zeroth command line argument, in other words the command that invoked the COBOL program.
  3. When a Format 7 ACCEPT statement is specified, the value of the command line argument indicated by the current argument position indicator is moved to dest-item (see ARGUMENT-VALUE in the SPECIAL-NAMES paragraph in Chapter 4).
  4. The current argument position indicator is determined by the following:
    • In the absence of a Format 4 DISPLAY, the initial value of the current argument position indicator is 1.
    • The current argument position indicator is incremented by 1 after execution of a Format 7 ACCEPT statement.
  5. When a Format 8 ACCEPT statement is specified, the value of envlog-value is moved to dest-item (refer to ENVIRONMENT-VALUE and ENVIRONMENT-NAME in the SPECIAL-NAMES paragraph in Chapter 4). This value represents the value of the environment variable or system logical named by the current ENVIRONMENT-NAME item.
  6. stment3 is executed if an attempt is made to read beyond the last argument on the command line, or if the argument does not exist.
  7. stment4 is executed if the name of the environment variable or logical has not been set by a Format 5 DISPLAY, or if the environment variable or logical does not exist.
  8. stment5 is executed if the exception condition does not exist.

Technical Notes

All Formats

  1. On OpenVMS systems, if the data transfer is from a terminal, Ctrl/Z is equivalent to an end-of-file indication. <>
  2. On Tru64 UNIX systems, if the data transfer is from a terminal, Ctrl/D is equivalent to an end-of-file indication. <>

Format 1

  1. An ACCEPT statement without the FROM phrase takes input from the default input device (the keyboard). To take input from a file on Tru64 UNIX systems, the environment variable COBOL_INPUT can be used to specify a text file containing input data. To take input from a file on OpenVMS systems, the logical COB$INPUT or SYS$INPUT can be used to specify a text file containing input data.
    Alternatively, input device redirection (<) can be used on Tru64 UNIX systems to name an input file.
  2. An ACCEPT statement that includes the FROM phrase transfers data from the file-device-name associated with the SPECIAL-NAMES paragraph description of input-source.
  3. On OpenVMS systems, the object of a logical name is not necessarily a device. Therefore, no open mode is implied. As a result, input-source can be associated with any device-name in the SPECIAL-NAMES paragraph. For example, input-source can refer to PAPER-TAPE-PUNCH as well as PAPER-TAPE-READER. <>
  4. An end-of-file indication during ACCEPT statement execution with an AT END phrase causes control to transfer to the AT END imperative statement.
  5. An end-of-file indication during ACCEPT statement execution without the AT END phrase is an error. The program terminates abnormally.
  6. The ACCEPT statement fills dest-item with spaces if the input is an empty record (for example, a carriage return only).
  7. On Tru64 UNIX, you can enter a maximum of 256 characters during a Format 1 ACCEPT statement. <>

Formats 3 and 4

  • The Hewlett-Packard extensions to the ACCEPT and DISPLAY statements support data input and display only on VT100 and later terminal types, including emulators of these terminal types.
  • On OpenVMS Alpha and I64 systems, control sequences from SMGTERMS.TXT are used to accomplish cursor positioning, screen erasure, and video attributes. Refer to the chapter on support for non Hewlett-Packard terminals of the OpenVMS RTL Screen Management (SMG$) Manual if you wish to customize SMGTERMS.TXT. <>
  • You should accept data only from input fields that are within screen boundaries. That is, the terminal operator should see all the characters entered (assuming the NO ECHO, CONVERSION, and PROTECTED phrases are not specified). If you accept data from an input field that positions the cursor outside screen boundaries, the result is not an error condition, but your program might produce unexpected results.
    Values for screen boundaries depend on the terminal attributes. Refer to the appropriate terminal user's guide for more information on screen boundaries.
  • Line positioning can be a one- or two-step process. The first (or only) step is absolute positioning, which is using the value of line-num or line-id to determine the line position. The second step is relative positioning, which is adding the value of plus-num to line-id to determine the line position. Relative positioning beyond the bottom line of the current screen results in scrolling.
    For example, suppose that the screen for which you are programming has a maximum of 24 lines and you need to scroll the screen up one line before accepting data. The following sample statements illustrate how to use relative positioning to accomplish this operation (assume ITEMA has a value of 14, and the current line position is 20):


    ACCEPT DEST-EXAMPLE FROM LINE NUMBER PLUS 5.
    ACCEPT DEST-EXAMPLE FROM LINE NUMBER ITEMA PLUS 11.
    

    The following sample statements would produce undefined results because absolute line positioning is beyond the bottom of the screen (assume ITEMB has a value of 25):


    ACCEPT DEST-EXAMPLE FROM LINE NUMBER 25.
    ACCEPT DEST-EXAMPLE FROM LINE NUMBER ITEMB.
    ACCEPT DEST-EXAMPLE FROM LINE NUMBER ITEMB PLUS 0.
    

    The last ACCEPT statement illustrates that use of the PLUS option does not necessarily mean that scrolling will always occur. Absolute line positioning always occurs before the relative positioning specified by the PLUS option. In this case, line-id (ITEMB) has a value of 25. Therefore, the line position is outside the screen boundary before the PLUS option executes, and program results are undefined.
  • When you use the CONTROL KEY phrase, key-dest-item stores the terminator key code. The HP COBOL User Manual contains information on these key code values in its description of programming video forms.
  • In Formats 3 and 4, the maximum number of characters in dest-item or key-dest-item is 1024.
  • When you use the CONTROL KEY phrase with the PROTECTED WITH AUTOTERMINATE phrase, and the maximum number of characters is entered to terminate the ACCEPT statement, key-dest-item is filled with spaces.
  • The ALPHABET clause has no effect on the CONVERSION clause for either ACCEPT or DISPLAY.
  • Unexpected behavior can occur when an ACCEPT statement with the EDITING, PROTECTED, and DEFAULT IS CURRENT phrases and without the CONVERSION phrase is executed. The behavior occurs when a numeric data item has a negative scale factor or is signed. To avoid this behavior, it is suggested that the CONVERSION phrase be used in these circumstances.

Additional References

Examples

In the following examples, the character s represents a space. The examples assume that the time is just after 2:15 P.M. on October 7, 1992. The Environment and Data Divisions contain the following entries:


SPECIAL-NAMES.
        CONSOLE IS IN-DEVICE.
DATA DIVISION.
01      ITEMA   PIC X(6).
01      ITEMB   PIC 99V99.
01      ITEMC   PIC 9(8).
01      ITEMD   PIC 9(5).
01      ITEME   PIC 9(6).
01      ITEMF   PIC 9.
01      ITEMG   COMP-1.
01      ITEMH   PIC S9(5) COMP.
  1. ACCEPT ITEMA.
    Input ITEMA
    COMPUTER COMPUT
    VAX VAXsss
    12.6 12.6ss
  2. ACCEPT ITEMB FROM IN-DEVICE.
    Input ITEMB Equivalent to
    1623 1623 16.23
    4 4sss Invalid data
    60000 6000 60.00
    -1.2 -1.2 Invalid data
    1.23 1.23 Invalid data
    COMPUTER COMP Invalid data
  3. ACCEPT ITEMB WITH CONVERSION.
    Input ITEMB Equivalent to
    1623 1623 16.23
    4 4sss 04.00
    60000 6000 60.00
    -1.2 -1.2 01.20
    1.23 1.23 01.23
    COMPUTER COMP Invalid data
    STATEMENT RESULT
    ACCEPT ITEME FROM DATE. ITEME = 921007
    ACCEPT ITEMC FROM TIME. ITEMC = 14150516 (OpenVMS and
    Tru64 UNIX)
    ACCEPT ITEMD FROM DAY. ITEMD = 92280
    ACCEPT ITEMF FROM DAY-OF-WEEK. ITEMF = 3
    ACCEPT ITEMA FROM TIME. ITEMA = 141505
    ACCEPT ITEME FROM TIME. ITEME = 150516
    ACCEPT ITEMD FROM DAY-OF-WEEK. ITEMD = 00003
    ACCEPT ITEMG WITH CONVERSION.  
    Input Result Equivalent to
    .123E-02 0.00123
    -12.3E+02 -1230
    1004E-07 1.004000E-04
  4. ACCEPT ITEMH WITH CONVERSION.
    Input Result Equivalent to
    27 27
    -44 -44


Previous Next Contents Index