COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Example 295 Reading and Writing Numeric Data
IDENTIFICATION DIVISION.
PROGRAM-ID. FRIENDLY-ACCEPT.
AUTHOR. KIT COBOL.
INSTALLATION. TRANSACTIONS ANONYMOUS.
DATE-WRITTEN. 29 FEBRUARY 1984.
DATE-COMPILED.
******************************************************
* This program shows the flexibility of the ACCEPT *
* statement. *
******************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP TXP.
OBJECT-COMPUTER. HP TXP.
SPECIAL-NAMES.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PICTURE 99999.
01 B PICTURE 999V999.
01 C PICTURE S999V999.
01 D PICTURE 999.999.
01 E PICTURE 9999V9999 USAGE IS COMPUTATIONAL.
01 F PICTURE
USAGE IS COMPUTATIONAL.
PROCEDURE DIVISION.
Z.
ACCEPT A. DISPLAY A.
ACCEPT B. DISPLAY B.
ACCEPT C. DISPLAY C.
ACCEPT D. DISPLAY D.
ACCEPT E. DISPLAY E.
ACCEPT F. DISPLAY F.
STOP RUN.
A record of the output of one execution of the program in Example 295 follows. Each ACCEPT
statement interprets the characters entered at each prompt (?) the same way as it would interpret
those characters as a numeric literal in a source program. Each DISPLAY statement converts the
value of a data item to a character-string that represents a numeric value for display.
?-1234.5678
01234
?-1234.5678
234.567
?-1234.5678
-234.567
?-1234.5678
234.567
?-1234.5678
1234.5678
?-1234.5678
-0001234.5678000
Logging Program Activity Information to a Terminal
Whenever a process sends a message to the system operator console terminal device ($0), the
operating environment can automatically duplicate the message to the standard log file, which
can be a terminal.
If you use the DISPLAY statement to send messages to the console, and therefore to the standard
log file terminal, you must associate a mnemonic name with $0 in the SPECIAL-NAMES paragraph.
This association is established at compilation time. Each DISPLAY statement transmits characters
to a single terminal or device.
Logging Program Activity Information to a Terminal 897