The LVAR command in Basic V can be very useful in debugging a program. It will list all the variables defined during the execution of a program, along with the names of any functions and procedures called, and any libraries loaded. However, LVAR is totally dynamic - a variable is only listed if it has actually been defined during execution. Another debugging tool is LIST IF. This will list all the lines containing the specified keyword, variable, etc. For example:
LIST IF PRINT
While LVAR and LIST IF can prove invaluable, it is sometimes very useful to be able to list out in one go all the variables, procedures etc., together with the numbers of all the lines referencing them. This is exactly what the cross-referencer presented here does.
The cross-referencer takes the form of a relocatable module, and this is supplied 'ready to load' on the monthly disc. The disc menu gives full instructions for loading the module. Also contained on the disc is the source code for the module, and this is fully documented making it easy to follow.
Once loaded, the cross-referencer module offers two commands:
*XREFD
and
*XREFP
These two commands are basically the same, except that the first displays the output on the screen, while the seconds prints the results as well. Used with no parameters, the current Basic program is cross-referenced, while adding an optional filename will load the named program and then cross-reference it. For example:
*XREFP BasicProg
The output produced by the cross- referencer is split into eight categories:
Procedures
Functions
Real variables
Real arrays
Integer variables
Integer arrays
String variables
String arrays
For each category, the total number of objects of that type is printed, followed by the name of each object and the numbers of the lines on which it occurs. The diagram shows an example of the display. During the process, Escape can be used to abort the operation. Pressing and holding Space will freeze the display until the key is released.
Obviously, the cross-referencer in itself cannot debug a program. However, armed with the list of occurrences, it should be relatively straightforward to pick out possible 'problem lines'.
For details of ordering the magazine disc, refer to the inside back cover.