Im slowly learning COBOL and am doing some challenges to get better but i am having a weird problem that i cant seem to trace and i wanted to see if anyone else can help
I double and triple checked that what was supposed to be in area A and B where in their proper col numbers
IDENTIFICATION DIVISION.
PROGRAM-ID. CIRCLES.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.
OBJECT-COMPUTER.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-CONSTANTS.
05 WS-PI PIC 9V99999 VALUE 3.14159.
01 WS-CIRCLE.
05 WS-AREA PIC 999V99 VALUE ZEROES.
05 WS-RADIUS PIC 9999V99 VALUE ZEROES.
05 WS-CIRCUMFERENCE PIC 99999V99 VALUE ZEROES.
01 WS-DISPLAY-VALUES.
05 WS-DISPLAY-AREA PIC ZZ99.99.
05 WS-DISPLAY-CIRCUMFERENCE PIC ZZ99.99.
PROCEDURE DIVISION.
0100-PROCESS-RECORDS.
DISPLAY "Please enter radius of circle: ".
ACCEPT WS-RADIUS.
COMPUTE WS-CIRCUMFRENCE = 2 * WS-PI * WS-RADIUS.
MOVE WS-CIRCUMFRENCE TO WS-DISPLAY-CIRCUMFRENCE.
DISPLAY "Circle Circumfrence is: ", WS-DISPLAY-CIRCUMFRENCE.
COMPUTE WS-RADIUS = WS-PI * WS-RADIUS * WS-RADIUS.
MOVE WS-AREA TO WS-DISPLAY-AREA.
DISPLAY "Circle area is: ", WS-DISPLAY-AREA
STOP RUN
compiler messages:
Circles.cbl:28: error: PROCEDURE DIVISION header missing
Circles.cbl:28: error: syntax error, unexpected level-number
Circles.cbl:29: error: unknown statement '05'
Circles.cbl:30: error: unknown statement '05'
Circles.cbl:34: error: syntax error, unexpected PROCEDURE
Circles.cbl: in paragraph '0100-PROCESS-RECORDS':
Circles.cbl:40: error: 'WS-RADIUS' is not defined
Circles.cbl:41: error: 'WS-CIRCUMFRENCE' is not defined
Circles.cbl:41: error: 'WS-PI' is not defined
Circles.cbl:41: error: 'WS-RADIUS' is not defined
Circles.cbl:42: error: 'WS-CIRCUMFRENCE' is not defined
Circles.cbl:42: error: 'WS-DISPLAY-CIRCUMFRENCE' is not defined
Circles.cbl:43: error: 'WS-DISPLAY-CIRCUM' is not defined
Circles.cbl:44: error: 'WS-RADIUS' is not defined
Circles.cbl:44: error: 'WS-PI' is not defined
Circles.cbl:44: error: 'WS-RADIUS' is not defined
Circles.cbl:44: error: 'WS-RADIUS' is not defined
Circles.cbl:45: error: 'WS-AREA' is not defined
Circles.cbl:45: error: 'WS-DISPLAY-AREA' is not defined
Circles.cbl:46: error: 'WS-DISPLAY-AREA' is not defined
After putting your program into an online compiler (code+results here) two issues were seen:
WS-CIRCUMFRENCE
-> WS-CIRCUMFENCE
As you seem to not use free format but the column based one I've removed that option (-free
from this project, fixed the issues specified above and added the minimal indentation, result: works like a charm.
I thought about possible issues but the only one I could think of was an additional specification of DECIMAL-POINT IS COMMA
- but that raises error: invalid level number '14159'
, or bad indentation (this would likely be seen); you may want to recheck that you don't do the indentation by TABs (their actual size may differ between what you editor shows and what the compiler uses [most compilers use a size of 8 spaces by default).