New project idea… already done

It’s 4AM and I can’t sleep. I was watching a YouTube video about COBOL on the Commodore 128. And it got me thinking about GnuCOBOL. I started looking at some of my old GnuCOBOL programs. And I realized I never wrote one to read EBCDIC data. You know hypothetically, an IBM shop sends me file in EBCDIC. So I think that’s the plan. I found some EBCDIC files in /home/bill/MyStuff/Computer_Simulator_Emulator/Emulators/Mainframe/Hercules/Tape/awsutilb-whb/ that I created with Jay Mosley’s maketape, I checked them with tapedump. I think to be consistent, tapedump should’ve been named dumptape. You know maketape… dumptape!

Ok, I forgot, but I found (by grep) that I did write a EBCDIC to ASCII program in 2017. Called COB05. I even copied it to github, 5 years ago. It compiles fine, but the input file is missing so I’ll have to recreate it.

This program assumes, all fields are EBCDIC. So it wouldn’t work properly for fields like comp-3.

Adding up the input fields, in the COBOL program, gives me a record length of 134. And I see I have some other ASCII files of 133 which would actually be 134 if you add the LF (end of line) character. I’m sure I used my Python program, to create the customer file. According to my comments, I used the Linux ‘dd’ command to convert an ASCII file to EBCDIC. But I didn’t give specifics.

OK... this
dd if="customer-fixed-5000(133).txt" of=file.ebc conv=ebcdic

Copied the directory COB05 to COB05-2 to make some minor cosmetic changes, such as align the PIC statements. Also reformat the ASCII table, I don’t know how those continuations (&) ended up on the same line. It looks better, but apparently wasn’t needed.

           78 ASCII   value 
          "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" &
          "0123456789 !" & '"' & "#$%&'()*+,-./:;<=>?@[\]^_`{|}~"&
          x'0A'.
           78 ASCII   value 
          "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" &
          "0123456789 !" & 
          '"' & 
          "#$%&'()*+,-./:;<=>?@[\]^_`{|}~"&
          x'0A'.

Apparently I used Mystuff for one of my input directories back then, and now I use MyStuff, so I had to change 1 line in the program… and it worked.

I was concerned it would be slow, and it may be. But for 5000 records…

bill@bill-MS-7B79:~/MyStuff/COBOL/progs/cob05$ time ./cob05 
Program Start!
+05000

real    0m0.109s
user    0m0.049s
sys     0m0.061s
bill@bill-MS-7B79:~/MyStuff/COBOL/progs/cob05$