Re: Prefs in a loadable ircle script...
Re: Prefs in a loadable ircle script...
- Subject: Re: Prefs in a loadable ircle script...
- From: David Blache <email@hidden>
- Date: Wed, 07 Feb 2001 16:56:47 -0600
on 2/7/2001 4:10 PM, giZm0 (email@hidden) wrote:
>
Now i am coding the version 2.0, wich absolutely needs a way to store prefs
>
on unload since ircle doesnt keep the properties of a script when you unload
>
it.
Hi Gizmo,
I am the creator of IRCmagic (
http://MicrocosmSoftware.com/ircmagic.html).
And I am happy to report that Ircle can and will save properties of loaded
scripts. All you need to do to get Ircle to save properties in a loaded
script is:
1) provide a unload() handler in the loaded script
2) return true as the result of the unload() handler
Like so:
on unload()
return true -- save all properties
end unload
If you do this, Ircle will diligently save all properties in your script
before unloading it. No workaround necessary.
>
My workaround was to create a "Script Application" which consists of
>
properties without any handlers or commands. The main scripts then launch this
>
application and make him change his properties. It works well and my variables
>
are stored and recovered properly on another load.
Good work around, but it need not be an application. A script would do just
fine.
You can load a script into another script, set its properties, and tell it
to do things, all without having to create an application. Some of us
fondly refer to these loaded sub-scripts as "script libraries", or "script
plug-ins". If you are interested in pursuing this workaround, say so and I
or someone else on the list will give you a short example.
>
The problem is, if the user doesn't have this application the first time he
>
runs the main script, he will be asked to choose an application (a wrong one
>
for sure...) and then he wont be able to run the script again even if he has
>
the application. Is there a way to make sure the user has the application
>
and that it is the correct one ?
To solve the "where is app?" problem you might try using the infamous
double-tell method combined with launching the application by relative path
if the application is always in a known location relative to the main
script. But like I said above, none of this is really necessary if all you
want to do is save properties in the main script on unload.
-David