Re: Passing variables between scripts
Re: Passing variables between scripts
- Subject: Re: Passing variables between scripts
- From: Richard Morton <email@hidden>
- Date: Fri, 20 Jun 2003 12:48:51 +1000
On Thursday, June 19, 2003, at 07:48 PM, Stephen Swift wrote:
I have a front script that can run many other scripts (chosen by
name). The
problem is that I have a variable that I need to pass to the script
from the
front script. I have thought of two options:
set the_script to load script "test.scpt"
set the_script's foo to bar
run the_script
The second option would use the run script command.
That's what I'd go for.
run script script -- the script text
(or an alias or file reference of a script file) to run
[with parameters a list of anything] -- list of parameters
I would assume parameters would be a good way to pass data, but I am a
bit
confused as to how this would be done.
Run script "test.scpt" with parameters {"some string"}
set scr to alias "path:to:compiled:script.scpt"
run script scr with parameters {p1, p2, [...]}
The problem I think is that I don't know how to write test.scpt so it
accepts the parameters.
on run paramList
-- do your stuff
end
or:
on run {p1, p2, [...]}
-- do your stuff
end
It's also possible to make the params optional &/or hook it up to an
'open' handler:
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 being called from
elsewhere
end
end
to open aliasList
run aliasList -- pass the dropped item(s) to the run handler
end
Would I use a subroutine...
I've used both with good results. You could have a handler in each
called script named main() (or whatever) & just call it, but you have
to load the script first - it's a variation of your first option.
...or can my parameter be
only a list of variables?
Not sure what you mean - what else would you like to pass? Hamburgers?
;-)
Cheers,
Long D'Stance-Runner
-- Lucille has messed my mind up, but I still love her
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.