typestar

ACCEPT FROM in COBOL

ACCEPT reads system values — the date and the clock — without touching the keyboard.

IDENTIFICATION DIVISION.
PROGRAM-ID. ACCEPT-DATE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TODAY-YMD   PIC 9(8).
01 CLOCK-HMS   PIC 9(8).
PROCEDURE DIVISION.
*> ACCEPT FROM reads system values instead of the keyboard.
    ACCEPT TODAY-YMD FROM DATE YYYYMMDD
    ACCEPT CLOCK-HMS FROM TIME
    DISPLAY "Log opened " TODAY-YMD " at " CLOCK-HMS
    STOP RUN.

How it works

  1. Two PIC 9(8) fields wait for the date and the time.
  2. ACCEPT TODAY-YMD FROM DATE YYYYMMDD asks for the four-digit-year form.
  3. ACCEPT ... FROM TIME delivers hours through hundredths, and DISPLAY prints both raw.

Keywords and builtins used here

The run, in numbers

Lines
12
Characters to type
341
Tokens
42
Three-star pace
40 tpm

At the three-star pace of 40 tokens a minute, this run takes about 63 seconds.

Type this snippet

Step 3 of 3 in The program shape, step 3 of 27 in Language basics.

← Previous Next →