Flight-Check your Xtras
Ever got to the end of a job, sat down to make the some projectors and wondered what Lingo Xtras you have ended up using (and need to include)? Or taken over someone elses project or revisited an old project of your own, and seen some vaguely familiar 'global functions' but can't remember which Xtra provides them? If so, this script might be of use to you. It has two main functions:
- WhoUsesXtra(xtraName) .
GetUsedXtras works by doing two things: firstly, it scans through all your
scripts look for the xtra keyword that it used to instantiate 'named' xtras.
For example, it will recognise the Lingo statement
fp = xtra("fileIO").new() as
using the Xtra called "fileIO". The second thing it does is locate any 'global
functions' provided by Xtras (i.e. functions that do not require a new instance
of the Xtra). For example, it will recognise re_grep, sleep and baWindowList
as global functions requiring PregEx, UIHelper and BuddyAPI respectively.
It does this by taking advantage of a quirk in Director where if you attempt
to put a xtra-provided function into a variable or the message window, a pointer
to the Xtra is returned. So using some crude regular expressions, this script
scans through all your lingo looking for likely candidates for Xtra functions
(words, not after comments, not enclosed in quotes etc) and see what happens
if these words are put into a variable.
WhoUsesXtra looks in the results of the scan, and returns the scripts that appear to use the named Xtra.
This is beta - hopefully there are no really nasty bugs in there. Known limitations include:
- When scanning for Xtras by name, it simply looks for the 'xtra' keyword
followed by optional parenthesis, and then the name in quotes. Therefore,
it will not find xtras instantiated by using a variable name such as
obj = xtra(myvar).new()
- When looking for 'used' Xtras, this script will try and ignored any commented out lingo. However, when looking for named xtras, it will also look in comments (this is partly by design, since I often list the xtras used by a script in a comment 'header')
- When looking for global Xtra functions, the technique described above will only work if the Xtra is installed in your Authoring environment
- No attempt at parsing Lingo to differentiate between variables and functions meaning the scanning process tries to check everything (which can be slow)