Reputation: 11
I'm watching COBOL tutorials, they use the "erase" statement to clean the screen and it doesn't work for me. The compiler indicates "syntax error, unexpected ERASE"
The code is:
DISPLAY "1.- CALC, 2.- CLOSE" ERASE.
It is my mistake?
I am using opencobol on ubuntu Sorry about my English, it's not my native language
Upvotes: 1
Views: 380
Reputation: 7297
As noted by @user207421 ERASE
is not a statement, it is a clause for the DISPLAY
statement, and it even is standardized - but (standard-wise) it needs a specification what you want to erase:
ERASE [END] [OF] LINE
[END] [OF] SCREEN
EOL
EOS
The syntax you have shown is actually the very non-standard, outdated Microsoft-COBOL DISPLAY
statement with ERASE phrase
.
If you still use open-cobol then the package is heavily outdated, there should be a new gnucobol package available in Ubuntu (otherwise you could build from source). Using GnuCOBOL 2.2 you get a nicer error message:
error: syntax error, unexpected ., expecting LINE or SCREEN
And then you can decide if you want the old ms-cobol variant (that's supported in GnuCOBOL, but only with the pos-specifier) or the standard variant (ERASE EOS
would be the compatible version and is supported by many compilers).
Upvotes: 3