在Ubuntu 18.10上使用GnuCOBOL 2.2.0。通过Michael Coughlan为“程序员开始COBOL”工作。 GnuCOBOL一直在编写本书的例子,直到第9章,这个程序:
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.
...在尝试编译时抛出以下错误:
~/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
如果所有£字符都被$替换,则编译成功。可能问题是GnuCOBOL不支持英镑符号吗?或者,是否必须以不同于键盘上的“£”方式输入它?
正如编译器所说:
CURRENCY的PICTURE SYMBOL必须是一个字符长
所以在源文件中找到的£
不是一个字符长 - 我假设你已经使用了UTF-8编码而GnuCOBOL并不直接支持任何多字节源编码(只要没有,你实际上就可以使用它了) “大小溢出”任何地方)。
如果可能,我建议将编码更改为ISO-8859-15,这是一个包含井号的单字节编码。