home *** CD-ROM | disk | FTP | other *** search
- EZLIST Formatted Listing of BASIC Programs
- by Joseph E. Laferriere
- from Computer Shopper June 1987
-
- If you frequently write long programs in BASIC, you're well aware of
- how debugging can be even more time consuming and frustrating than writing the
- original program. Since speed in BASIC often requires multiple statement
- lines, the listing produced by the LIST and LLIST commands can be confusing
- and hard to follow. A readout of the program in a more structured format,
- along with a list of GOTO and GOSUB statements, can help tremendously in
- tracking down elusive bugs and preventing them from giving rise to swarms of
- many-legged offspring.
- This program is based in part on an idea published by Geff Purcell in
- Soft Sector in April 1985 (Vol. 1, No. 9, pp 60-63). He suggested presenting
- programs in a structured format, with each portion of a multiple line printed
- as a separate line, as well as indenting the lines to show the connections
- between the beginnings and endings of FOR/NEXT and WHILE/WEND loops, and the
- relations between different parts of IF/THEN/ELSE statements. The result is a
- listing which is much easier to read than the standard BASIC listings.
- The variation presented here contains many of the basic principles of
- his original program, but with an improved searching algorithm, plus a few
- innovations of my own. One added feature is that the program in this article
- lists programs SAVEd in either ASCII or non-ASCII format. I do not generally
- store programs as ASCII files, since this requires more disk space than saving
- it in the non-ASCII mode. EZLIST offers you the option of listing files saved
- in option of listing files saved in the ASCII mode, but also is capable of
- handling non-ASCII files. It does this by starting the line numbering at
- 65000 (65535 being the maximum acceptable line number in BASIC), and CHAIN
- MERGE-ing the files to be listed. EZLIST then SAVE's itself, together with
- the files to be listed, in ASCII format as "TEMP.BAS", and lists this file
- until it reaches the maximum line number you previously specified. Very few
- programs use line numbers this high (this is the only one I've ever seen
- published); hence this program can list almost any program.
- EZLIST allows you to determine the beginning and ending lines to be
- listed, in case you only want to list part of the program. Default values are
- printed in square brackets on the screen. You need not know the actual
- minimum and maximum line numbers in your program; EZLIST will proceed until
- the line number exceeds the maximum limits you have set. This property can
- also be used to let EZLIST list itself, simply by entering an ending line
- number greater than or equal to 65470. The program also INPUTs the maximum
- number of lines per page and increments the lines printed as it goes along.
- If you are using continuous feed pater, you may wish to consider changing line
- 65330 to read
- 65330 M=M+1:LPRINT CHR$(-12*(M/N=M/N):RETURN
- At the head of the listing, EZLIST will print the name of the program,
- the date, and the length of the program listed. At the end it will print the
- number of lines of code and the number of separate command statements. It
- will then proceed to list all the GOTO and GOSUB statements in the program,
- sorted numerically. This even includes multiple statements such as "ON X
- GOSUB 100,200,300,400," and implied GOTO statements lacking the actual
- command, like "IF X THEN 100 ELSE 200." EZLIST stores the information on line
- numbers in temporary files ("TEMP.BBS" and "TEMP.BCS") until after the program
- listing is complete, then retrieves the information, and sorts it using a
- Shell-Metzger sorting routine according to the number after the GOTO or GOSUB
- command. It then prints all the line numbers containing the given branching
- command. This is especially useful if it is necessary to change variable
- names to remove a bug or change the way values must be assigned to variables
- prior to the execution of the subroutine; the list of which lines contain the
- errant GOSUB statement may well prevent you from creating new bugs to replace
- the old ones.
- The program then erases all three temporary files and DELETEs all
- lines up to and including 64999. This returns you to the BASIC command mode.
- All you have to do to list another program is enter RUN.
- Good luck! I hope this program saves you some time and headaches
- debugging programs.
-
-