Re: Snow Leopard osax security and 'run script' with parameters
Re: Snow Leopard osax security and 'run script' with parameters
- Subject: Re: Snow Leopard osax security and 'run script' with parameters
- From: "Stockly, Ed" <email@hidden>
- Date: Wed, 02 Dec 2009 13:21:18 -0800
- Thread-topic: Snow Leopard osax security and 'run script' with parameters
> Loaded script objects won't meet the objective to assemble script code on the
fly, since these are static, pre-compiled scripts rather than being dynamically
generated.
You can generate script objects on the fly and use them for dynamically
generated scripts. (Technically, you may actually be creating a script
object already) Check the archives.
>Also, the re-worked script doesn't make use of the reference. It's merely a
re-iteration of the first script with an extra unused parameter.
But the point is that the value of the parameter is carried into the run
handler. (But that's not really a parameter, its a list element inside a
parameter, see below).
This shows that both values are carried into the runhandler.
---
tell application "TextEdit"
set docRef to document 1
activate
set docRef to document 1
end tell
set theScript to "on run {X,y}" & return & "tell app \"TextEdit\" to set
text of document 1 to X" & return & "display dialog y as text " & return &
"end"
tell application "TextEdit" to run script theScript with parameters {"This
is the complex test.", text of docRef}
----
> The issue here appears to be related to the way that object references get
treated when they're specified as 'run script' parameters. Reference ownership
appears to be handed off to the current context:
No. A reference is a reference. They are free, not owned by anyone.
Run handlers generally don't have parameters. I believe they can take a
single parameter (just like open handlers) and in your script you are
passing a single parameter (a list with two elements).
Your run handler then distributes the list into a list of variables.
(as in: Set {x,y} to {1,2})
Put this inside your runhandler and you should get the same error:
tell application "TextEdit" to set docRef to document 1
> You'll see that the 'from' component of the event record indicates that the
reference is owned by the script, not TextEdit.
I don't have SN at work so I'll look at it this evening.
> tell application "TextEdit" to run script theScript with parameters {docRef}
You do not need to send the run script command to TextEdit. In fact apple's
Chris(x) will tell you explicitly not to do that.
Run script is an osax command, not a textedit command.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden