• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Parameters with run handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parameters with run handler


  • Subject: Re: Parameters with run handler
  • From: Richard Morton <email@hidden>
  • Date: Wed, 9 Jan 2002 18:30:45 +1100

On Wednesday, January 9, 2002, at 04:34 PM, Paul Berkowitz wrote:

Am I imagining it, or have I read here that it is possible to include a
parameter in list braces for a run handler, and to call it from another
script using the parameter, something like this:

tell application "Applet"
launch
run {someParameter}
end tell

Try this:

run script file "path:to:compiled:script:or:app" with parameters paramList


or

set f to load script file aCompiledScriptsPath
tell f to run {someParameter}

This works:

run script f with parameters paramList


where the script application or compiled script in question has a run
handler:

This works under 10.1.1:

Save as compiled script -

on run {bNum}
beep bNum
display dialog "I was supposed to beep " & bNum & " times, but I didn't."
end run

This calls it -

set s to alias "path:to:above:script:file" - or file spec
run script s with parameters {3}

--> {button returned:"OK"}

It only beeps once, but the dialog comes up. Can't have everything I guess...


I can find nothing about this in the ASLG or O'Reilly's Nutshell, and it
doesn't seem to work in OS X. So I must be imagining it. But I'd swear I
read about it here.

It's actually in the Standard Additions dictionary in Scripting Commands - 'run script' is what you want. It has been discussed here as well. I've used it with compiled scripts as the target, as per the above example. Works well under classic MacOS. Pretty handy feature IMO.

Some testing here suggests that it should be possible to make it optional in a run handler as well, which is pretty cool. I tested a one with a param & Script Editor told me the class of the param was script if nothing was passed. This is from memory & untested:

to run paramList
if class of paramList is not <<script>> then -- chevrons around 'script'
-- no param, a normal run
else
-- have param, running from open handler or elsewhere
end
end

to open aliasList
run aliasList -- pass the dropped item(s) to the run handler
end

I got (something like) this to work when I was developing something under 9.1, but I ended up not using it & haven't got back to it. It looked like it should work reliably though.

Cheers,

Richard Morton
-- not enjoying 'Mail.app' much...


  • Prev by Date: Re: Parameters with run handler
  • Next by Date: Re: AppleScript Studio Help (Kinsella, John R.)
  • Previous by thread: Re: Parameters with run handler
  • Next by thread: Re: Parameters with run handler
  • Index(es):
    • Date
    • Thread