Problem:
This sample demonstrates how to add line numbers to your source program
Resolution:
INTRODUCTION
==========
COBOL source decks (punch cards) had line numbers in colums 1-6. Fixed-format COBOL source files still reserve those columns for line numbers, but they are seldom used. Some programmers prefer to have line numbers in source, but there are no supported methods of doing so.
As a programming example, this source demonstrates:
- parsing the command line,
- determining whether the operating system is Unix or not,
- determining the nonblank length of a string,
- determining whether or not a string is entirely numeric,
- use of CBL_ library routines,
- and use of environment variables within a COBOL program.
SOURCE FILES:
==========
Program Files Description
---------------- -----------------------------------------------------------
linenum.cbl Source in Unix format. Will compile correctly in non-Unix environments, but
Windows notepad will not display correctly. Use Wordpad or Net Express instead.
REQUIREMENTS:
==========
Any of the following Micro Focus COBOL environments or later: Object Cobol Developer Suite v4.1 for DOS, OS/2, or Unix NetExpress, any version Server Express, any version Micro Focus Studio, any version
OPERATION:
========
Compile to an executable file (.exe in DOS, Windows, or OS/2). Unix compile command:
cob -x linenum.cbl
Run from a command prompt.
Command line syntax: linenum sourcefile[,outfile] [increment] [start]
linenum sourcefile will renumber sourcefile in-place starting with line number 10 and incrementing by 10.
outfile, if specified will receive the output. sourcefile will be left unchanged.
increment is the amount added to each successive line number. Default is 10.
start is the number of the first source line. Default is the value of increment.
For example,
linenum infile,outfile 37 26
will produce outfile as a copy of infile with the first line numbered 26 and successive lines numbered as the previous line plus 37.
If any line number overflows six digit positions, the program terminates with an error message and no output.
See comments near beginning of source for further information.
CAUTION: The program assumes the input file is a COBOL source in fixed format, but does not check. Use of the optional outfile parameter is recommended to avoid inadvertent overwrite of an incorrect file.
REFERENCES
========
COBOL product documentation.
NOTE:
====
This source is unsupported.
==========================================================
Keywords: Example, sample, demo, demonstration, UNIX, linenum.zip
demo.ex
demo.ne
demo.se