COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-4
ACCEPT With Mnemonic-Name
If the response is in numeric literal format, the ACCEPT statement converts it to a
numeric literal in an intermediate data item and then moves the value of the
intermediate data item to accept-name. If accept-name has no fractional part,
any necessary truncation of the intermediate data item value deletes the rightmost
digits of the value; otherwise, the transfer of the data from the intermediate item to
accept-name follows the rules for the MOVE statement.
In Example 9-2, the ACCEPT statement reads an alphanumeric value into an
accept-name whose length (60 characters) exceeds the record size of the
terminal (40 characters).
Figure 9-1 shows the run-time interactions at the terminal. The user’s responses to
the ACCEPT statement’s prompts are in bold font. When the user enters the
fortieth character with no carriage return, the ACCEPT statement prompts again.
Example 9-1. ACCEPT Statement Reading From a Terminal
WORKING-STORAGE SECTION.
01 COMMAND-IN PICTURE X(7) VALUE SPACES.
88 ADD-C VALUE "ADD".
88 UPDATE-C VALUE "UPDATE".
88 DELETE-C VALUE "DELETE".
88 EXIT-C VALUE "EXIT".
...
PROCEDURE DIVISION.
...
DISPLAY "ENTER COMMAND"
ACCEPT COMMAND-IN
IF ADD-C ...
Example 9-2. ACCEPT Statement Reading Alphanumeric Data
WORKING-STORAGE SECTION.
01 HEADING-IN PICTURE X(60) VALUE SPACES.
...
PROCEDURE DIVISION.
...
DISPLAY "Enter heading (up to 60 characters)"
ACCEPT HEADING-IN
DISPLAY HEADING-IN
MOVE HEADING-IN TO HEADING-OUT
...