This 'XRef' program produces an alphabetical cross reference list of all the names, numbers, and words in an *.AHK file, showing the source line numbers where these items occurred. Any quoted information is also included.
XRef can also process DOS batch files, as well as C and JS files.
A cross reference listing can be very useful for locating where program variables are set and used, and is also handy for determining unused variable names when allocating new ones.
An optional extra 'Function Map' can also be produced, showing where in the program functions and subroutines are defined, and where they are referenced. This map is only a part of the main report, however it displays the data in the same order that it occurs in the program being analysed.
There is an option to process a subset of the script; 'Get script subset'. When prompted, enter the starting and ending line numbers separated by a space. This facility can be used to analyse a self-contained portion of a script, such as a function definition.
A particular set of options plus setup can be saved as the default, and a different set of options can be saved for each script to be processed, if necessary.
As well, a different default set of options plus setup can be saved for a general subset-type report (select 'Get script subset' with any line numbers first), and yet another set of subset-type options can also be saved for the currently selected script.
The type of default options in use is shown between hyphens in the title bar at the top of the Options window.
Any script options previously saved may be erased - click on the 'Update...' checkbox to see the different saving and erasing options. To access the subset-type defaults for the currently selected script, first select 'Get script subset' (with any line numbers), then the 'Update...' checkbox and button will process the subset-type defaults.
The generated report is shown in Notepad and may be automatically printed to the default printer if required. If a 'page size' is supplied in the setup, the report will be formatted 'n/up' to take up less space.
To show the report correctly, Notepad should be set to use a mono-spaced font. This can be achieved by using the 'Mono' button to set Notepad to its defaults. The old position and size of Notepad's window is preserved.
Script comments are usually excluded from the report, however there is an option to include this information if required. (As syntax analysis is rudimentary in this program, it is possible that valid data in some scripts may be inadvertently flagged as comments.)
AHK '#include's are not processed. For the cross reference list this doesn't really matter, as each library file can be processed separately, and they don't usually change often. Any optional function maps generated, however, will be incomplete if the '#include'd files contain function definitions. I have no plans to change this at present.
To process one or more scripts without any user intervention, you can drag and drop the scripts onto XRef.exe (or a shortcut pointing to XRef.exe), and the scripts will be processed automatically using the default options (script or overall). The same will happen if you run XRef.exe supplying the script names as parameters. (If a script can't be found, an error message is shown, then the usual file selection dialog will be displayed.)
Screen shot and output snippets
XRef can be downloaded from here. The zip file includes source and executable.