• 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: Still trying to learn list subtleties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still trying to learn list subtleties


  • Subject: Re: Still trying to learn list subtleties
  • From: red_menace <email@hidden>
  • Date: Sat, 26 May 2012 12:43:42 -0600

Hello,

Another way would be to match a choice from one list (the descriptive list to choose from) into
another list (the actual value), for example:


set black to {"0", "0", "0"}
set blueGray to {"8000", "8000", "10000"}
set white to {"65535", "65535", "65535"}
set red to {"65535", "0", "0"}
set manual to missing value

set theChoiceList to {"black", "blueGray", "white", "red", "Choose Color"}
set theColorList to {black, blueGray, white, red, manual}

set theColor to (matchChoice from theChoiceList into theColorList)
if theColor is false then error number -128
if class of theColor is not list then set theColor to (choose color)
return theColor


to matchChoice from sourceList into objectList -- match choice from one list into another
set theChoice to (choose from list sourceList) as text
repeat with X from 1 to (count of sourceList)
if (item X of sourceList) = theChoice then return (item X of objectList)
end repeat
return false -- no match, or cancel
end matchChoice


Dave


On May 26, 2012, at 11:31 AM, email@hidden wrote:

Date: Sat, 26 May 2012 11:01:50 -0600
From: Robert Poland <email@hidden>
To: AppleScript Users <email@hidden>
Subject: Still trying to learn list subtleties
Message-ID: <email@hidden" style="font-size: 11px; ">email@hidden>
Content-Type: text/plain; charset="windows-1252"

Hi,

Looking for busy work…

In this script clip I don't see the need for the long "if then" but I'm at a loss on how to deal with "the choice" as a variable. Or maybe I need to be choosing a variable???

set blueGray to {"8000", "8000", "10000"}
set black to {"0", "0", "0"}
set white to {"65535", "65535", "65535"}
set red to {"65535", "0", "0"}
set manual to "Choose Color"
set theColorList to {"Black", "blueGray", "White", "Red", "Manual"}

tell application "GraphicConverter"
activate
set {theChoice} to choose from list theColorList default items "blueGray" with title "Color Selection"
display dialog theChoice
set theChoice to {theChoice}
set background color to theChoice
end tell

(* if theChoice = "bluegray" then
set theChoice to blueGray
else if theChoice = "Black" then
set theChoice to black
else if theChoice = "White" then
set theChoice to white
else if theChoice = "Red" then
set theChoice to red
else if theChoice = "Manual" then
set theChoice to choose color
else
set theChoice to blueGray -- default
end if *)

TIA,

Robert Poland - Fort Collins, CO


 _______________________________________________
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

  • Prev by Date: Re: AppleScript-Users Digest, Vol 9, Issue 226
  • Next by Date: Re: AppleScript-Users Digest, Vol 9, Issue 180
  • Previous by thread: Re: Still trying to learn list subtleties
  • Next by thread: Re: AppleScript-Users Digest, Vol 9, Issue 226
  • Index(es):
    • Date
    • Thread