• 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: Luther Fuller <email@hidden>
  • Date: Mon, 24 Jan 2011 13:24:22 -0600

On Jan 24, 2011, at 11:30 AM, Marconi wrote:

Is there a lookup function in AppleScript that will look in a list of values (a table?) and get a corresponding value?

It seems that you are looking-up a word associated with a single character.
So, why not use the id of the character to calculate an index for a list?
Like this ...

property phoneticList : {"Zero", "One", "Two", "Three", "Four"}

on run
set charIndex to my getCharIndex("2")
if charIndex > 0 then
item charIndex of phoneticList
end if
end run

on getCharIndex(theChar)
set charID to (id of theChar)
if (97 ≤ charID) and (charID ≤ 122) then return (charID - 32 - 47)
if (48 ≤ charID) and (charID ≤ 57) then return (charID - 47)
if (65 ≤ charID) and (charID ≤ 90) then return (charID - 47)
return 0
end getCharIndex

You will have to complete the list phoneticList .

 _______________________________________________
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

References: 
 >A Lookup Function? (From: Marconi <email@hidden>)

  • Prev by Date: Re:Lookup Table
  • Next by Date: Re: getting focus, slow getting icon position in window
  • Previous by thread: Re: A Lookup Function?
  • Next by thread: Re: A Lookup Function?
  • Index(es):
    • Date
    • Thread