Re: adding parameters to run command
Re: adding parameters to run command
- Subject: Re: adding parameters to run command
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 22 Apr 2005 23:52:44 -0700
Title: Re: adding parameters to run command
On 4/22/05 11:09 PM, "Donald Hall" <email@hidden> wrote:
Is there any way to pass parameters to the run command of a script object?
e.g. This works:
script s1
on run
display dialog "script s1"
end run
end script
run s1
Event Log:
----------------------------------
tell current application
display dialog "script s1"
{button returned:"OK"}
end tell
-----------------------------------
But this:
script s1
on run {p}
display dialog "script s1 " & p
end run
end script
tell s1 to run {"parameter"}
results in a syntax error: {"parameter"} doesn't understand the run message.
Note: I do not want to use the 'run script' scripting addition.
In that case you can't use parameters with the run handler. But since you don't need to, why should you care? Just male a another handler, with parameters, and call that. The run handler only operates if you double-click an applet - you don't need to call it. Call another handler:
script s1
on whatever(p)
display dialog "script s1 " & p
end whatever
end script
tell s1 to whatever("parameter")
--> dialog "script s1 parameter"
If there's some reason why you might need to actually run s1 (i.e. it's not an internal script object but an applet) and at other times call its whatever handler, you'd need a setup like this:
script s1
on run
whatever("default")
end run
on whatever(p)
display dialog "script s1 " & p
end whatever
end script
--
Paul Berkowitz
_______________________________________________
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