Re: Example: Can an AppleScript accept arguments
Re: Example: Can an AppleScript accept arguments
- Subject: Re: Example: Can an AppleScript accept arguments
- From: bryan <email@hidden>
- Date: Mon, 01 Jul 2002 12:11:37 -0400
The way to send arguments to applescripts, is to sent them events after you activate them.
I am not familiar with the commands to do this from the event side <<event ?????>> though;
sorry.
From another applescript you tell the target to "handler_name (argument)" as follows:
--script_1
activate--not necessary if script_2 is running
tell script_2 to do_dialog("hi")
--end script_1
--script_2
on o_dialog (arg1)
set argument to arg1
if argument = "hi" then
display dialog "Hello there!"
else if argument = "bye" then
display dialog "See you later..."
else
display dialog "I don't understand " & argument
end if
end o_dialog
--end script_2
I know there is an event which you can generate from a command line, but I do not know
what it is. I am sure someone on this list knows what it is though. yoiu have to be sure the
application process (the script) is running, set the target to the script, and send the
event to
the target.
Anybody know what the events are?
(Sorry in advance for the multipost)
Bryan Kaufman
"Spunk S. Spunk III" wrote:
>
It looks like Applescript only accepts filenames/paths/folders as arguments.
>
Here's an example of what I would like to see (although it doesn't work!):
>
>
on run (arg1)
>
set argument to arg1
>
if argument = "hi" then
>
display dialog "Hello there!"
>
else if argument = "bye" then
>
display dialog "See you later..."
>
else
>
display dialog "I don't understand " & argument
>
end if
>
end run
>
>
This returns an error stating you can't set <<script>> to a string (in this
>
case the variable "argument"). I want to know if there is a way for the
>
argument to be handled as text in order to run tests on (if/then). This
>
could perhaps be accomplished with a "set argument to arg1 as text" or maybe
>
"as argument" or something.
>
>
This functionality may in fact exist... Hence my question. If not, why not
>
add it. Again, this could only be used from the command line or another
>
script but I think it would find many uses.
>
>
Anyone?
>
>
Spunk
>
_______________________________________________
>
applescript-studio mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
>
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type text/x-vcard which had a name of bryan.vcf]
_______________________________________________
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.