|
Using the symbol table
The last and undocumented
way to check for most Xtras' presence is also due to Bruce Epstein.
In LIAN page 521-525, he describes the Director symbol table in
a great way, and he gives us a way to determine whether a symbol
(e.g. command name, member type, variable name, Lingo symbol, user
defined symbol, user defined handler names...) is in this global
symbol inventory:
on existingSymbol
symbolName
global gInitialSymbolCount
-- Record the last symbol defined when first called
if voidP(gInitialSymbolCount) then
newsymbol = symbol("uniqueSymbol"
& the ticks)
gInitialSymbolCount = (newSymbol + 0)
end if
-- Compare the number of the symbol to test to gInitialSymbolCount
checkSymbol = (symbol(symbolName) + 0)
if checkSymbol < gInitialSymbolCount then return
TRUE
else return FALSE
end
We first create a new
unique symbol to get the actual number of symbols present in the
symbol table.
If the param symbolName
that is passed-in (as string) is a predefined Director symbol, we'll
get a symbol number less than gInitialSymbolCount;
if it has not been present in the symbol table before, we'll create
it and its number will be greater than gInitialSymbolCount.
There are good reasons
NOT to use this code for a serious Xtra check. If a symbol is used
before the test is executed (e.g. because you named a global with
the same name, or you used the Xtra in a previous session), the
symbol exists and the test will always return true - even if the
Xtra to test does not exist. The demo movie contains this option
- use it for fun, NOT for a Xtra check.
Baring that in mind, it
works if you pass in either an Xtra's handler name (for Lingo Xtras)
or an asset type (for AssetXtras). Both have to be strings!
put existingSymbol
("flash")
-- 1
put existingSymbol ("vectorshape")
-- 1
put existingSymbol ("closed") -- a #vectorshape property
-- 0 -- use member type instead!
put existingSymbol ("ExportMedia") -- a JavaConvert Xtra
function
-- 1
There is no way though
to check for Agent Xtras and MIX Xtras like "Mix Services",
"JPEG Export", "Image Translator Helper" with
this method.
|