As I continue to work through the HTML objects I am incorporating into a project, I found I was repeatedly writing variants of a code block to step through a string to analyze its makeup. I finally got smart and exported the routine to a callable module, which I am adding here. I have already added one additional statistic to the code, and it would be easy to add more, so this is a routine that can be quickly tailored for additional requirements..
To install the source programs (the subprogram and a test program), and compile them, execute the bash script: downloads/stringStats.setup [md5: 1909a3d3ff3659b45117bc0faa9c2284]. 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, then execute the GnuCOBOL compiler to compile them into the run unit for the test program. The GnuCOBOL compiler must be installed prior to executing the bash script.
Output from the test/verification program:
If you want to be able to dynamically call the subprogram move the object module (stringStats.so) to a location included in your COB_LIBRARY_PATH.
* Updated September 20, 2019 * I was tired of looking for and copying the Working-Storage fields for this, and a few other, routines, so I updated the installation script to provide a copybook that may be used in the calling program for this routine. For easiest use, you should copy the copybook file into the directory that GnuCOBOL searches during compile time for copy books (on my Linux system that is /usr/local/share/gnucobol/copy).
This page was last updated on September 20, 2019.