• 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: simple problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple problem?


  • Subject: Re: simple problem?
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 21 Nov 2007 16:58:50 -0800


On Nov 20, 2007, at 12:00 AM, Richard Morton wrote:

On 20/11/2007, at 6:23 PM, Skeeve wrote:
Richard Morton wrote:
set group to ( choose from list {"Group A", "Group B", "Group C", "Group D", "Group E", "Group F"} with prompt "Please select the group letter you have been assigned:" ) as string
This is correct and I think a good solution.
This is correct by accident and a not-so-good solution.

Not at all.

Actually, I agree with Skeeve. The difficulty with "as string" is that, while it works for this case, and that's not an accident, it's not really saying what you mean. This leads to conceptual difficulties with how lists work and non-functioning code later on. For instance, say you want to be able to have more than one group in effect. You might find the "with multiple selections allowed" parameter -- and then the "if" tests, as currently written, wouldn't work. You might also note the difficulty with using "display dialog" as your only debugging tool -- because it coerces its argument to text, it can obscure differences in what values are. (This isn't a 'class' mismatch, it's just that the values aren't the same: x is not the same thing as {x}.)


To sum up: saying 'item 1 of (choose from list ...)' means you understand that you're dealing with a list. However, an even better solution would be to use "contains" instead of "is" for the tests: you're then not assuming that your list contains exactly one item.


--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: simple problem?
      • From: Paul Scott <email@hidden>
References: 
 >simple problem? (From: Celine Latulipe <email@hidden>)
 >Re: simple problem? (From: Paul Scott <email@hidden>)
 >Re: simple problem? (From: Richard Morton <email@hidden>)
 >Re: simple problem? (From: Richard Morton <email@hidden>)

  • Prev by Date: Re: Script fails with Leopard.
  • Next by Date: Re: XMLlib -- > Xpath
  • Previous by thread: Re: simple problem?
  • Next by thread: Re: simple problem?
  • Index(es):
    • Date
    • Thread