Had to rename this gem so that it could be easily searched and found in
the Rev Use-List!!!
Thanks Trevor :-)
-Chipp
Trevor DeVore wrote:
That being said, I prefer a different method when dealing with externals.
When using externals I like to be able to load/unload the external
whenever I want. This is necessary if you want the ability to update
an external while your application is running. Now, in order to unload
an external it must be attached to a stack that 1) has the
destroyWindow property set to true and 2) is open, not just in memory.
With that in mind, whenever an application launches it can create a
stack at runtime (never actually exists on disk) that has the
properties we need. For example:
on loadAppExternals
local tExternals
----------
--> EXTERNALS
----------
put "myExternal.bundle" &cr& "myExternal.dll" into tExternals
----------
--> CREATE EXTERNALS STACK IN MEMORY
----------
if tExternals <> empty then
if there is not a stack "myExternals" then
reset templateStack
set destroyWindow of templateStack to true
set destroyStack of templateStack to true
set visible of templateStack to false
set externals of templateStack to tExternals
create stack "myExternals"
reset templateStack
end if
go stack "myExternals"
start using stack "myExternals"
end if
end loadAppExternals
Now you can call loadAppExternals whenever you need to load externals
for your application. If you need to unload the externals just close
the stack:
close stack "myExternals"
The externals will be unloaded from memory and you can update the
external files on disk.
If you ever need to check if an external loaded correctly or is
available you can check the externalPackages property of the
"myExternals" stack. Every external has a string identifier that the
person who made the external assigns to it. This shows up in the
externalPackages property of the stack only when the external has
successfully loaded. So if you have an external that is identified
with the string "MySuperExternal" you could have some code like this:
on checkAppExternals
local tRequiredExternals,tExternal
if there is not a stack "myExternals" then
answer "You didn't bother loading the externals stack. Try
again."
return empty
end if
put "MySuperExternal" into tRequiredExternals
repeat for each line tExternal in tRequiredExternals
if tExternal is not among lines of externalPackages of stack
"myExternals" then
answer "Oh where, oh where has my external gone?"
return empty
end if
end repeat
end checkAppExternals
This method of working with externals has proven to work really well
for me.
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution