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.
Related
I'm writing a COBOL program with NETEXPRESS.
I wrote $ZZZZ9.99 in detail line and it works when I use school desktop but I get an error "PICTURE string has illegal character " if I compile it with my laptop.
05 DL-WAGE PIC $ZZZZ9.99 VALUE ZERO.
Can anyone help me resolve this issue?? I used the same version of NEXEXPRESS in both places.
Params include arabic digits also which I want to convert it into digits:-
"lexus/yr_٢٠٠١_٢٠٠٦"
I tried this one
params[:query].tr!('٠١٢٣٤٥٦٧٨٩','0123456789').delete!(" ")
but it gives an error
Encoding::CompatibilityError Exception: incompatible character encodings: UTF-8 and ASCII-8BIT
for that I do
params[:query].force_encoding('utf-8').encode.tr!('٠١٢٣٤٥٦٧٨٩','0123456789').delete!(" ")
how I can convert this?
If you have enforced UTF-8 encoding then this should work fine.
str = "lexus/yr_٢٠٠١_٢٠٠٦"
str.tr('٠١٢٣٤٥٦٧٨٩','0123456789')
returns "lexus/yr_2001_2006"
ASCII 8-bit is not really an encoding. It is binary data, not something text based. Transcoding ASCII 8-bit to UTF-8 is not a meaningful operation. I would recommend ensuring that the request that passes the query parameter through your textfield is using valid string encoding, if you can control this. You can use String#valid_encoding? method in ruby to check you are receiving a correctly encoded string.
If I check the charset of a file that I'm reading from I get:
text/plain; charset=us-ascii
So I am reading it in like:
File.open(#file_path, r:ASCII) do |f|
f.each_line do |line|
line = line.rstrip.force_encoding("ASCII")
Which works fine until I hit this line:
"Seat 2: tchin\xE9 ($423 in chips)"
Where I get this error:
ArgumentError: invalid byte sequence in US-ASCII
This line looks like this in my text editor:
"Seat 2: tchin? ($423 in chips)"
If I try reading it in as UTF-8 instead of ASCII, I get the same error:
ArgumentError: invalid byte sequence in UTF-8
Any ideas of what I should be doing. I have tried using iconv to convert it from ASCII to UTF-8 and and I get this error:
Iconv::IllegalSequence: "\xE9 ($423 in chips"
ASCII is a 7-bit encoding (max 127, 128 characters), not 8 bit (max 255, 256 characters).
E9 (Decimal 233, probably a é) is higher then 128. So you have no ASCII, the ruby error message is correct.
I expect it is cp1252.
Update:
I'm quiet sure, it is a é. The sentence "Seat 2: tchiné ($423 in chips)" makes sense (I don't know what it is, but it seems to be something in Poker.
This line looks like this in my text editor:
"Seat 2: tchin? ($423 in chips)"
Your editor may not display the é, so it displays a substitute character.
Reading the file as "r:ISO8859-1" worked.
I received files which, sadly, I cannot get info about how they were generated. I need to parse these files.
The file is entirely ASCII besides for one character: 0xDB (in decimal it gives 219).
Obviously (from looking at the file) this character is a currency symbol. I know it because:
it is mandatory for these files to contain a currency symbol anywhere an amount appears
there's no other currency symbol (neither $ nor euro nor nothing) nowhere in the files
everytime that 0xDB appears it's next to an amount
I think that in these files that 0xDB is supposed to represent the Euro symbol (it is actually very highly probable that this 0xDB appears everywhere a Euro symbol is supposed to appear).
The file command says this about the files:
ISO-8859 English text, with CRLF, LF line terminators
An hexdump gives this:
00000030 71 75 61 6e 74 20 db 32 2e 36 30 0a 20 41 49 4d |quant .2.60. AIM|
^^ ^
The files are all otherwise normally formatted/parsable. Actually I'm getting all the infos fine besides for that weird 0xDB character.
Does anyone know what's going on? How did a currency symbol (supposedly the euro symbol) somehow become a 0xDB?
It's neither ISO-8859-1 (aka ISO Latin 1) nor ISO-8859-15 because in both case code point 219 corresponds to 'Û' (just as Unicode codepoint 219 is 'LATIN CAPITAL LETTER U WITH CIRCUMFLEX').
It's not extended-ASCII.
It could be Mac OS Roman
It's MacRoman. In fact it has to be -- that's the only charset in which the Euro sign maps to 0xDB.
Here's the full charset mapping for MacRoman.
Using the macroman script, one learns:
$ macroman 0xDB
MacRoman DB ⇒ U+20AC ‹€› \N{ EURO SIGN }
You can go the other way, too:
$ macroman U+00E9
MacRoman 8E ⇐ U+00E9 ‹é› \N{ LATIN SMALL LETTER E WITH ACUTE }
And we know that U+20AC EURO SIGN is indeed a currency symbol because of the uniprops script’s output:
$ uniprops -a U+20AC
U+20AC <€> \N{ EURO SIGN }:
\pS \p{Sc}
All Any Assigned InCurrencySymbols Common Zyyy Currency_Symbol Sc Currency_Symbols S Gr_Base Grapheme_Base Graph GrBase Print Symbol X_POSIX_Graph X_POSIX_Print
Age=2.1 Bidi_Class=ET Bidi_Class=European_Terminator BC=ET Block=Currency_Symbols Canonical_Combining_Class=0 Canonical_Combining_Class=Not_Reordered CCC=NR Canonical_Combining_Class=NR Script=Common Decomposition_Type=None DT=None East_Asian_Width=A East_Asian_Width=Ambiguous EA=A Grapheme_Cluster_Break=Other GCB=XX Grapheme_Cluster_Break=XX Hangul_Syllable_Type=NA Hangul_Syllable_Type=Not_Applicable HST=NA Joining_Group=No_Joining_Group JG=NoJoiningGroup Joining_Type=Non_Joining JT=U Joining_Type=U Line_Break=PR Line_Break=Prefix_Numeric LB=PR Numeric_Type=None NT=None Numeric_Value=NaN NV=NaN Present_In=2.1 IN=2.1 Present_In=3.0 IN=3.0 Present_In=3.1 IN=3.1 Present_In=3.2 IN=3.2 Present_In=4.0 IN=4.0 Present_In=4.1 IN=4.1 Present_In=5.0 IN=5.0 Present_In=5.1 IN=5.1 Present_In=5.2 IN=5.2 Present_In=6.0 IN=6.0 SC=Zyyy Script=Zyyy Sentence_Break=Other SB=XX Sentence_Break=XX Word_Break=Other WB=XX Word_Break=XX _X_Begin
0xDB represents the Euro sign in the Mac OS Roman character encoding.
I'm new to Fujitsu COBOL 3.0 software. I tried executing a simple program. The code and errors are as follows. Everything in program appears to be correct. Can anyone help me out? Any prestandards are to be followed in this software?
The sample cobol program is:
IDENTIFICATION DIVISION.
PROGRAM-ID. ShortestProgram.
PROCEDURE DIVISION.
DisplayPrompt.
DISPLAY "I did it".
STOP RUN.
--------------------------------------------------------------------------------------
** DIAGNOSTIC MESSAGE ** (NOPRGMID)
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 0: JMN1102I-S IDENTIFICATION DIVISION HEADER IS MISSING. HEADER ASSUMED TO BE CODED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1005I-W CHARACTER STRING 'DENTIFICATION' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1356I-W INVALID WORD 'DENTIFICATION' IS SPECIFIED IN IDENTIFICATION DIVISION. IGNORED UNTIL NEXT PARAGRAPH OR DIVISION.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 2: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 2: JMN1005I-W CHARACTER STRING 'ROGRAM-ID' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 4: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 4: JMN1005I-W CHARACTER STRING 'ROCEDURE' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 6: JMN1004I-W RESERVED WORD 'DISPLAY' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 7: JMN1104I-S PROGRAM-ID PARAGRAPH IS MISSING. PROGRAM-NAME GENERATED BY SYSTEM.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 7: JMN1004I-W RESERVED WORD 'STOP' MUST START IN AREA B. ASSUMED TO START IN AREA B.
STATISTICS: HIGHEST SEVERITY CODE=S, PROGRAM UNIT=1
The warnings (referring to area B) seem to suggest your code should by starting in the second column of each line. Which is why it's finding e.g. "DENTIFICATION" instead of "IDENTIFICATION".
I've never developed in COBOL but I vaguely remember that the first column has to be blank, or * for a comment: the warning messages seem to indicate that / - and D are valid values too.
UPDATE: Google suggests that COBOL compiler ignores the first 6 columns and that column 7 has a special significance (D for debugging, * for comment, ...). Though maybe the behaviour is compiler-specific. So I suspect your problem is that your code is starting in col 7 where it should be col 8.
Shift everything over 7 columns so that IDENTIFICATION DIVISION starts in column 8 and all subsequent lines began in column 8 or greater.
There's also a compiler switch (can't remember off the top of my head) that allows you to start in col 1
Taking a WAG (wild-ass guess) here. Haven't cobol'd since my last year of college.
Your error message says, at the bottom,
STATISTICS: HIGHEST SEVERITY CODE=S, PROGRAM UNIT=1
Okay, so I figure you have some warnings (possibly CODE=W), and one or more errors that are actually causing your program to fail.
So, scanning the error message, I see lots of W-s, and one line with an S:
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB
7: JMN1104I-S PROGRAM-ID PARAGRAPH IS
MISSING. PROGRAM-NAME GENERATED BY
SYSTEM.
So it seems you're missing your Program-ID paragraph. Looking at your program, I do see a n identification division, which has a program-id.
I can conclude four things from this:
1) Your identification division paragraph is malformed
2) As Neil said, you aren't running your snippet, but a sample that does not have an ID paragraph. Open sample7.cob and see
3) Some other issue is causing the error, but it is being hidden or misinterpreted as an ID paragraph error