I have been working for a while on converting a set of programs I wrote decades ago in BASIC that I use to catalog physical books in my home library. It is a low priority, so progress is slow. I had already written an ISBN (International Standard Book Number) validation program in COBOL and recently saw a note listing programs at Rosetta Code that needed COBOL versions, so I cobbled together a program matching their specifications from my code. Then I visualized a few changes that would be desirable for my own uses, so again dug into the program, resulting in this version. It has two entry points: the first - validateISBN13 - will validate a passed 13 digit ISBN; the second - calculateISBN13 - will compute the correct check digit and insert it into the passed ISBN. For either entry point, the COBOL RETURN-CODE register will contain an appropriate value to indicate the outcome (0: the ISBN passes the check digit test, -1: the length of the passed ISBN code is not 13 characters, -2: the passed ISBN code contains a non-numeric character, -4: the computed check digit does not match the check digit supplied in character 13).
To install the source programs (the subprogram and a test program), compile them, and execute the test program, execute the bash script: downloads/ISBN13.setup [md5: b586d158634657ec333d0ecb34659fb6]. Right click and save the script in the location where you want the source program to reside, then execute it. It will create two files containing the source programs, call the GnuCOBOL compiler to compile them into the run unit for the test, and then execute the test program. The GnuCOBOL compiler must be installed prior to executing the bash script.
Output from the script:
jay@Phoenix ~ $ ./ISBN13.setup 9781734314502 (good) 9781734314509 (bad) 9781734314502 (generated) 9781788399081 (good) 9781788399083 (bad) 9781788399081 (generated) 978162979705 (bad) 9781629797052 (generated) jay@Phoenix ~ $
This page was last updated on April 06, 2021.