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 per script.
The type of default options in use is shown between hyphens in the title bar at the top of the 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, 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 can 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.
'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.)
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, the usual file selection dialog will be displayed instead.)
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.
Screen shot and output snippets:-
XRef can be downloaded from here. The zip file includes source and executable.
11 Mar 2016 -
19 May 2016 -
The 'mono' button now doesn't generate a UAC prompt and keeps Notepad's previous position and size.
The 'Print Report' option has been updated.
11 July 2016 -
Added two options for 'tighter' formatting, which will generate more compact reports.
Separated out the 'Exit Notepad' option from 'Print report'.
The Notepad window now comes to the front after a report is generated.
Can select a new file to process from the Options window.
Eliminated the possibility of some incorrect references when generating a Function Map.
12 July 2016 -
Fixed a bug when generating a Function Map for some .js scripts.
Fixed a bug when generating a Function Map for .ahk scripts when including comments.
12 August 2016 -
Fixed a formatting issue when generating a Function Map and Lines/page is zero.
02 November 2016 -
Added an option to analyse a subset of the script.
The Cross Reference List file is now saved as Unicode (UTF-8).
15 January 2017 -
Can save separate defaults for the 'Get script subset' option - see amended documentation.
Supports AHK2 Unicode variable names.
17 February 2017 -
Added drag and drop facility and updated documentation.
19 March 2017 - updated download link.