Using GnuCOBOL 2.2.0 on Ubuntu 18.10. Working through 'Beginning COBOL for Programmers' by Michael Coughlan. GnuCOBOL has been compiling the book's examples without trouble up until Chapter 9, when this program:
IDENTIFICATION DIVISION.
PROGRAM-ID. Listing9-2.
AUTHOR. Michael Coughlan.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
CURRENCY SIGN IS "£".
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Edit1 PIC £££,££9.99.
PROCEDURE DIVISION.
Begin.
MOVE 12345.95 TO Edit1
DISPLAY "Edit1 = " Edit1
STOP RUN.
...throws the following errors when attempting to compile:
~/Documents/COBOL$ cobc -x -free Listing9-2.cbl
Listing9-2.cbl: 8: error: PICTURE SYMBOL for CURRENCY must be one character long
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: 11: error: invalid PICTURE character '�'
Listing9-2.cbl: in paragraph 'Begin':
Listing9-2.cbl: 15: error: invalid MOVE statement
If all the £ characters are replaced by $, the compile succeeds. Could the problem be that GnuCOBOL does not support the British pound sign? Or, does one have to enter it a different way than just pressing '£' on the keyboard?
As the compiler says:
PICTURE SYMBOL for CURRENCY must be one character long
so the £
found in the source file is not a character long - I assume you've used UTF-8 encoding and GnuCOBOL doesn't directly supports any multi-byte source encoding (you actually get away with it as long as there is no "size overflow" anywhere).
If possible I suggest to change the encoding to ISO-8859-15 which is a single-byte encoding which has the pound sign included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With