Date: Wed, 30 Oct 1996 20:50:06 -0800 From: "Terry R. Schussler"I thought some of you might be interested in the following handler/function I wrote in Lingo to prevent what I suspect will be the beginning of a lot of Xtra user technical support questions. If anyone has a cleaner solution or one which addresses Tool Xtras, I'm all eyes.Subject: Determining if an Xtra is Installed
Determining if an Xtra is Installed
When you build a project which relies on an Xtra being installed in either
the Xtras folder accompanying Director or a runtime projector or in the
Shockwave support folder you need to be able to determine if in fact the
Xtra is there. While authoring with Lingo Xtras, this is fairly easy since
you can use the showXlib command to visually identify this during authoring
mode.
However, when you are actually running your project, this may be more difficult. Using Lingo Xtras you can accomplish this by enumerating the name of xtra and searching through all of the Xtras you may have. Here's a nearly complete Lingo function you can use to scan for specific Lingo, Asset and Transition Xtras (Tool Xtras not implemented yet.)
on isXtraInstalled xtraNameOrSymbol, xtraType
-- version 0.9 10/16/96
-- xtraNameOrSymbol: a string or a symbol identifying the xtra in question
-- xtraType: a symbol (#lingo, #asset, #transition, #tool) identifying the type of xtra
-- note: xtraType is optional and will be defaulted to #lingo
-- created by Terry R. Schussler, g/matter, inc.
-- copyright (c) 1996 by Terry R. Schussler
-- this handler may be used freely as long as this notice remains intact
-- Limitations for #asset and #transition xtra types:
--
-- #1: this function may fail to return the correct result if:
-- the first argument is passed as a symbol
-- the Xtra which registers the symbol was the *last* Xtra installed
-- in this circumstance, the function will assume the Xtra is NOT installed.
--
-- #2: calling this function more than once while passing a symbol for the first argument
-- this function requires the first argument
if voidP(xtraNameOrSymbol) then return #ERR
-- assume that the xtra is a Lingo Xtra if no type is specified
if voidP(xtraType) then put #lingo into xtraType
-- parse the appropriate data structures to see if the xtra is around
case xtraType of
#lingo :
-- coerce the first argument to a string (just in case)
put string(xtraNameOrSymbol) into xtraNameOrSymbol
-- search through the internal list of xtras
put the number of Xtras into totalXtras
repeat with theXtra = 1 to totalXtras
if the name of xtra theXtra = xtraNameOrSymbol then return TRUE
end repeat
return FALSE
#transition, #asset :
-- check for the symbol
-- first create a unique symbol
put the ticks into uniqueInteger
put value("#zzz"&string(uniqueInteger)) into uniqueSymbol
-- now grab the new symbol's value
put uniqueSymbol-0 into uniqueSymbolTableValue
-- convert the first argument to a symbol if required
if NOT symbolP(xtraNameOrSymbol) then
put value("#"&string(xtraNameOrSymbol)) into xtraNameOrSymbol
end if
-- now get the integer value of the symbol
put xtraNameOrSymbol-0 into symbolTableValue
--- now compare the symbol table values
-- (the -1 is to accommodate the potential that the first argument is passed as a symbol)
if symbolTableValue < uniqueSymbolTableValue - 1 then
return TRUE
else
return FALSE
end if
#tool :
-- this component will be completed in the 1.0 release of this function - TRS
-- pseudo-code outline
-- search through the items installed into the Xtras folder on the disk
-- get the path to the projector or Director
-- walk through the Xtras folder up to 5 levels looking for:
-- ".X16", ".X32", ".DXR", ".DIR" or Macintosh Xtra files
return #UNKNOWN
end case
end isXtraInstalled