Re: True Optional Handler Parameters (Positional)
Re: True Optional Handler Parameters (Positional)
- Subject: Re: True Optional Handler Parameters (Positional)
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 22 Feb 2004 17:31:12 -0800
On 2/22/04 5:09 PM, "Michael Terry" <email@hidden> wrote:
>
Have you ever wanted to include optional parameters, but were stymied
>
by AppleScript's seeming lack?
>
>
As a novice, it quickly becomes clear that you can't do something like
>
this:
>
>
on showArgs(args)
>
repeat with i in args
>
display dialog i
>
end repeat
>
end showArgs
>
>
showArgs()
>
--> {} doesn't match the parameters {args} for showArgs.
>
>
showArgs("jello")
>
--> j
>
--> e
>
--> l
>
--> l
>
--> o
>
>
Oops!
>
>
Then you might have stumbled across the following, inspiring a sliver
>
of hope:
>
>
showArgs("jello","brand","gelatin")
>
--> j
>
--> e
>
--> l
>
--> l
>
--> o
>
>
Oops, again, but at least there wasn't an error. How to get the other
>
arguments? After beating your head against the wall for a few minutes
>
(or hours, if you're like me), you gave up that approach as a loss.
Why don't you just do:
on showArgs(args)
repeat with i in args
display dialog i
end repeat
end showArgs
showArgs({"jello", "brand", "gelatin"})
The 'repeat with i in ...' syntax requires a list. So just give it a list
and keep it happy.
--
Paul Berkowitz
_______________________________________________
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.