Problem:
Problem sample sources sent in to SupportLine are often missing copy members and/or critical directives or compiler command line options. A listing (.lst) file can contain all the information, but considerable hand-editing is required to turn the .lst file into usable source and directives.
An attempt to complie the .lst file directly will fail due to the embedded page titles.
Sometimes the source file is lost, but a listing file remains. An automated means of retrieving the source could save time spent on other copying methods.
Resolution:
The attached COBOL source, list2src.cbl, runs on Unix or Windows and will work with Unix or Windows listing files.
Compile the source to executable: cob -x list2src.cbl
Run with a listing file specified as the first and only command line argument:
./list2src /somewhere/listing.lst (note: Windows file specs are equally valid)
Listing file name on command line is required.
Program will output zero or more files, depending upon what is found in the listing:
Program source (if present) with all extraneous matter removed as listing.cbl, where "listing" is the supplied name of the .lst file. E.g. tictac.lst would produce tictac.cbl, etc.
Directives (if SETTINGS directive was used) as listing.dir
Options (if VERBOSE directive was used) as listing.opt This is in a format suitable for use as a COBOPT file.
Notes:
Program source lines which extend into or beyond column 73 can cause the animator display to fail to synchronize with the source. Such lines are tagged with a warning comment in the source file. All warnings and the source lines which generate them are also displayed to standard output.
Free-format source comments with asterisk in column 1 will be discarded as indistinguishable from other extraneous matter in the listing file. However, the executable COBOL source statements will be intact.
File names with backslashes (Unix) or slashes (Windows), or extra dots will be misparsed and will result in either a partial file name being used or an error message and no output. Slashes and backslashes as platform-appropriate directory name separator characters in a file specification are expected and handled correctly.
If the file supplied is not a Micro Focus - generated .lst file, output, if any, will be unpredictable, but input file will not be modified in any case.



