WORKING-STORAGE in COBOL
Three level 01 items declare the lighthouse's data before any statement runs.
IDENTIFICATION DIVISION.
PROGRAM-ID. WORKING-STORAGE-TOUR.
DATA DIVISION.
WORKING-STORAGE SECTION.
*> Level 01 items declare a name, a picture, and often a value.
01 STATION-NAME PIC X(12) VALUE "Gull Rock".
01 LAMP-TURNS PIC 9(3) VALUE 148.
01 OIL-GALLONS PIC 9(2)V9 VALUE 6.5.
PROCEDURE DIVISION.
DISPLAY "Station: " STATION-NAME
DISPLAY "Turns tonight: " LAMP-TURNS
DISPLAY "Oil on hand: " OIL-GALLONS " (V marks an unseen point)"
STOP RUN.
How it works
DATA DIVISION.andWORKING-STORAGE SECTION.open the data half of the program.- Each
01item pairs a name with aPICpicture and an optional startingVALUE. 9(2)V9stores digits only — theVmarks a decimal point that is never written.
Keywords and builtins used here
DATADISPLAYDIVISIONIDENTIFICATIONPROCEDURESECTIONSTOP
The run, in numbers
- Lines
- 13
- Characters to type
- 450
- Tokens
- 48
- Three-star pace
- 40 tpm
At the three-star pace of 40 tokens a minute, this run takes about 72 seconds.
Step 2 of 3 in The program shape, step 2 of 27 in Language basics.