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
- Two
PIC 9(8)fields wait for the date and the time. ACCEPT TODAY-YMD FROM DATE YYYYMMDDasks for the four-digit-year form.ACCEPT ... FROM TIMEdelivers hours through hundredths, andDISPLAYprints both raw.
Keywords and builtins used here
ACCEPTDATADISPLAYDIVISIONIDENTIFICATIONPROCEDURESECTIONSTOP
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.
Step 3 of 3 in The program shape, step 3 of 27 in Language basics.