• 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: True Optional Handler Parameters (Positional)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: True Optional Handler Parameters (Positional)
      • From: Christopher Nebel <email@hidden>
    • Re: True Optional Handler Parameters (Positional)
      • From: Michael Terry <email@hidden>
References: 
 >True Optional Handler Parameters (Positional) (From: Michael Terry <email@hidden>)

  • Prev by Date: Efficiently using whose on Address Book users
  • Next by Date: Re: Efficiently using whose on Address Book users
  • Previous by thread: True Optional Handler Parameters (Positional)
  • Next by thread: Re: True Optional Handler Parameters (Positional)
  • Index(es):
    • Date
    • Thread