This code processes a formatted text file into COBOL code. Ick. 8^) Running from the Web frontend (http://johnbintz.dragonfire.net/cobolkiller), it accepts one parameter - "cobolcode", a TEXTAREA input from HTML. The report format is pasted into the TEXTAREA then sent to the script. An example report file would look like this:
The first line of the report file is ignored. I use it to line up and measure across columns. After that, the file is processed word by word in this way:
If the word has two or more capital Xs, the number of Xs is counted and a PIC clause for X(length) is returned
If the word has two or more 9s, the number of 9s is counted and a PIC clause for 9(length) is returned.
If neither of these two occur, the word is placed into a FILLER (kinda like a constant) and the FILLER is assigned a PIC clause of X(length)
I also wrote a version to work with CICS BMS macros, which are even more longwinded. Enjoy!