Re: persistence of script properties
Re: persistence of script properties
- Subject: Re: persistence of script properties
- From: Michael Terry <email@hidden>
- Date: Sat, 5 Mar 2005 20:21:12 -0800
On Mar 5, 2005, at 1:39 PM, Donald Hall wrote:
Thanks for the explanation, Paul. It works as you say. Unfortunately,
when telling a script object to run, there does not seem to be a way
to pass parameters to the script. So, it looks like you have a choice
- persistent properties in your script or the ability to pass
parameters to a run handler.
Weeellll, it is *possible* to have both. I use the following--in what I
tell myself is semi-practical fashion--as part of a simple library
loading mechanism. Run the following demonstration a few times:
------------------------------------------------------------------------
---------------------------------
on run script args
script
property parent : beginning of args
on run
return continue run rest of args
end run
end script
run result
end run script
script whatevs
property val1 : 1
property val2 : 1
on run eachArg
set {val1, val2} to {val1 + (eachArg's item 1), val2 + (eachArg's
item 2)}
end run
end script
on run
set scriptFile to (path to temporary items as string) & "whatevs.scpt"
try
set whatevs to load script file scriptFile
on error
store script whatevs in file scriptFile
end try
display dialog "val1: " & val1 of whatevs & return & "val2: " & val2
of whatevs
run script {whatevs, 1, 1}
store script whatevs in scriptFile with replacing
end run
------------------------------------------------------------------------
---------------------------------
Note that you have to follow the calling format of the redefined run
script command. The redefinition eliminates the 'run script' addition,
and makes sure you execute the target script's run handler in the
current context.
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden