• 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: A Lookup Function?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Lookup Function?


  • Subject: Re: A Lookup Function?
  • From: Steve Thompson <email@hidden>
  • Date: Mon, 24 Jan 2011 20:53:23 +0000


On 24 Jan 2011, at 17:30, Marconi wrote:

What's the most efficient way to store and initialize the table, and look up the values?

I'd create the table like this:

set phonetics to {{"A", "Alpha"}, {"B", "Bravo"}, {"C", "Charlie"}, {"D", "Delta"}, {"E", "Echo"}, {"F", "Foxtrot"}, {"G", "Golf"}, {"H", "Hotel"}, {"I", "India"}, {"J", "Juliet"}, {"K", "Kilo"}, {"L", "Lima"}, {"M", "Mike"}, {"N", "November"}, {"O", "Oscar"}, {"P", "Papa"}, {"Q", "Quebec"}, {"R", "Romeo"}, {"S", "Sierra"}, {"T", "Tango"}, {"U", "Uniform"}, {"V", "Victor"}, {"W", "Whiskey"}, {"X", "X-Ray"}, {"Y", "Yankee"}, {"Z", "Zulu"}}
tell application "Database Events"
set theDatabase to make new database with properties {name:"Phonetics"}
tell theDatabase
repeat with aPair in phonetics
set theRecord to make new record with properties {name:item 1 of aPair}
tell theRecord
make new field with properties {name:"Pronunciation", value:item 2 of aPair}
end tell
end repeat
end tell
end tell

And then look up values like this:

tell application "Database Events"
get record 1 of database "Phonetics" whose name = "F"
--> record id 317594819 of database "Phonetics"
get value of field "Pronunciation" of record id 317594819 of database "Phonetics"
--> "Foxtrot"
end tell
 _______________________________________________
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: A Lookup Function?
      • From: Steve Thompson <email@hidden>
References: 
 >A Lookup Function? (From: Marconi <email@hidden>)

  • Prev by Date: Re: A Lookup Function?
  • Next by Date: Re: A Lookup Function?
  • Previous by thread: Re: A Lookup Function?
  • Next by thread: Re: A Lookup Function?
  • Index(es):
    • Date
    • Thread