• 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: Choose from list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Choose from list


  • Subject: Re: Choose from list
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 19 Jul 2005 16:21:27 -0700

On Jul 19, 2005, at 12:41 PM, Robert Poland wrote:

set theList to {"Lying", "Sitting", "Standing", "All"}
set theChoice to {}
set theChoice to (choose from list theList default items {"All"} with prompt "Select Blood Pressure(s) to Plot." with multiple selections allowed) as string
set m to {}
set n to 0
repeat with i from 1 to number of items in theList
set x to item i of theList
set n to n + 1
if x is in theChoice then copy n to end of m
end repeat
m

The way you're processing the result into a list of indices is a bit odd. It works (at least here), but involves an unnecessary variable in the loop, and the coercion to string wastes time and will cause trouble if you ever have an item that is a substring of another. (Try adding an extra item "Falling" and then pick only "Falling" to see what I mean.) Consider this instead:


set theList to {"Lying", "Sitting", "Standing", "All"}
set theChoice to (choose from list theList default items {"All"} with prompt "Select Blood Pressure(s) to Plot." with multiple selections allowed)
set m to {}
repeat with i from 1 to number of items in theList
if item i of theList is in theChoice then copy i to end of m
end repeat
m



--Chris Nebel AppleScript and Automator Engineering

P.S.: Seeing as how multiple selection is allowed, isn't "All" as a separate choice sort of redundant? Try saying "choose from list theList default items theList"...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Choose from list
      • From: Timothy Bates <email@hidden>
References: 
 >Re: Choose from list (From: Andrew Oliver <email@hidden>)
 >Re: Choose from list (From: Robert Poland <email@hidden>)
 >Re: Choose from list (From: Michelle Steiner <email@hidden>)
 >Re: Choose from list (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Incrementing variables
  • Next by Date: Re: Incrementing variables
  • Previous by thread: Re: Choose from list
  • Next by thread: Re: Choose from list
  • Index(es):
    • Date
    • Thread