Re: is it possible to load a script library with a creation handler
Re: is it possible to load a script library with a creation handler
- Subject: Re: is it possible to load a script library with a creation handler
- From: "Jason W. Bruce" <email@hidden>
- Date: Sat, 31 Mar 2001 14:06:35 +0000
I hope I'm not misunderstanding your question, but, if you load a script
object as a parent to your current script, the loaded script's run handler
will execute. So if you have staircase as a separate file which you load
into your current script as follows:
Property parent: load script alias "Hard drive:staircase"
then your current script will execute the run handler in staircase. If you
call returnParameters() at the top level of your staircase script, then
returnParameters() will automatically execute when you run your current
script.
Jason Bruce
Timothy Bates wrote:
>
hi there,
>
I now understand how neat script libraries are (took me a while).
>
>
I have a nifty library which should be initialised when I create an instance
>
of it.
>
>
I was doing this with a handler that contained the script, but I want to
>
move to loading the scripts from file. Unfortunately, now I cannot see how
>
to force the user to initialise the object when they create it because you
>
can't pass parameters to the load script command. Is there anyway around
>
this?
>
>
To help explain, my old script (gutted for simplicity) was:
>
>
set myStaircase to my createNewAdapativeStairCase({1,2,3})
>
>
returnParameters() of myStaircase
>
--> {1,2,3}
>
>
on createNewAdapativeStairCase(parameterList)
>
script staircase
>
property parameters: parameterList
>
on returnParameters()
>
return parameters
>
end returnParameters
>
end script
>
end createNewAdapativeStairCase
>
>
Does anyone out there have any clues on including a handler like this in a
>
loadable script object so that it is called at load time? Is thought that
>
load like be like "run" so I could simply include the code and gets called
>
automagically, but no dice.
>
>
tim