Re: Parameters with run handler
Re: Parameters with run handler
- Subject: Re: Parameters with run handler
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 09 Jan 2002 10:06:25 -0500
>
Date: Tue, 08 Jan 2002 21:34:49 -0800
>
Subject: Parameters with run handler
>
From: Paul Berkowitz <email@hidden>
>
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
>
or
>
set f to load script file aCompiledScriptsPath
>
tell f to run {someParameter}
This part below is correct:
>
on run {someParameter}
>
--script
>
end run
but the "run" calls above are not. To send paramters to a script,
you have to use the scripting addition command "run script".
run script (yourScript) with parameters (yourParameterList)
This is very different from using the native "run" command.
>
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.
In an earlier version the "run script" osax, I *think* the syntax may
have been different, (ie: the "with parameters" parameter may have been
added later).
>
In the case of the compiled script or non-stay-open applet, it doesn't
>
matter: you can just change a property when you load the script, and store
>
it if necessary, or not. But a stay-open applet is "busy" if open, so you
>
can't store a property change. Being able to use a parameter would be a
>
great help.
I once employed the trick of sending data parameters to a script
simply by passing them to an "open" handler. :)
If you design your entire script around handlers, then you need
not bother with a run handler, as any handler can begin your flow
control:
on main(a, b, c)
-- put you entire script here
end main
-- When "double-clicked", or simply run normally, these default
-- values will be used. If this is a stay-open script, then
-- other scripts can call it with parameters, main( x, y, z ).
--
main("default", "values", 3.14159)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www.AppleScriptSourcebook.com/>
on error number -128
end try
}