Software Utility Generates Line Numbers For Code Listings

April 17, 2000
Several vendors of integrateddevelopment-environment (IDE) software don’t provide the capability of printing line numbers with program code listings. This additional line-number information can improve code readability and make the debugging process...

Several vendors of integrateddevelopment-environment (IDE) software don’t provide the capability of printing line numbers with program code listings. This additional line-number information can improve code readability and make the debugging process more efficient. Other information, such as a printout of the date and time, also can simplify monitoring a project’s progress during the software development cycle, and at the same time improve documentation.

With this in mind, a small software utility has been written in Visual Basic 5.0 that can easily be used by hardware and software engineers alike. This utility offers the flexibility of printing the code anywhere in a page, taking various margin settings into account. The flow chart of this utility shows the process (Fig. 1).

The software is used through a GUI form, which initially displays information such as the default printer and the selected page’s dimensions (Fig. 2). The file to be printed is chosen using a command button on the form. A simple click of the “Print Now” button will print the selected file. But before the actual printing takes place (via the print_data subroutine), checks are performed to determine whether the selected margins and print area are within the selected page boundaries. In case of an error, the user is informed through a message box.

If no errors are detected, the selected file is accessed in input mode (open fname for input as #1) and one complete line of data (inpdata) is obtained at a time. This line of data then is appended to the current line number (line_count variable). The completed line (inpdata) is checked to ensure that it can be printed (height-wise) on the given page. If it does not fit in the present page, a new page is started (using the new_page_inf subroutine).

The program line also is checked to see if it can be printed in the given linewidth dimensions. If it doesn’t fit, then a text-wrapping routine (text_wrap subroutine) is called. The routine splits the line data into multiple lines for printing.

The name of the file and the page number is printed at the top of each printed page. The date and time at which the printout was performed is printed at the page bottom. This is a helpful piece of information both during and after the design’s development cycle, as well as during the documentation process.

Margin information is given in the program code itself in this program. However, it also can be passed to the printing routine through another GUI form, allowing the additional flexibility of changing margins at run time. Similarly, the ability to modify other printing properties can be incorporated into the software. The associated code listing for this generator can be found in the Ideas for Design section of Electronic Design’s web site at www.elecdesign.com.

Sponsored Recommendations

TTI Transportation Resource Center

April 8, 2024
From sensors to vehicle electrification, from design to production, on-board and off-board a TTI Transportation Specialist will help you keep moving into the future. TTI has been...

Cornell Dubilier: Push EV Charging to Higher Productivity and Lower Recharge Times

April 8, 2024
Optimized for high efficiency power inverter/converter level 3 EV charging systems, CDE capacitors offer high capacitance values, low inductance (< 5 nH), high ripple current ...

TTI Hybrid & Electric Vehicles Line Card

April 8, 2024
Components for Infrastructure, Connectivity and On-board Systems TTI stocks the premier electrical components that hybrid and electric vehicle manufacturers and suppliers need...

Bourns: Automotive-Grade Components for the Rough Road Ahead

April 8, 2024
The electronics needed for transportation today is getting increasingly more demanding and sophisticated, requiring not only high quality components but those that interface well...

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!