• 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: "email@hidden" <email@hidden>
  • Date: Mon, 24 Jan 2011 10:15:23 -0800

On Jan 24, 2011, at 9:30am, Marconi wrote:

> For example, I'd enter "email@hidden" and it would parse each character and pop up a window with the text:
>
> Mike Alpha Romeo Charlie Oscar November India at Mike Delta Charlie Charlie Lima X-ray X-ray Victor India dot Charlie Oscar Mike.
>

Here's a very simple way to do this in appleScript. May not be the most efficient, but it works.
----------------------
property lookUpTable : ".	dot
@	at
1 one
2	two
9	nine
a	Alpha
B	Bravo
c	Charlie
d	Delta
i	India
l	Lima
m	Mike
n	November
o	Oscar
r	Romeo
v	Victor
x	X-ray
Z	Zulu
"
set sourceString to "email@hidden"
set endString to {}
set sourceString to items of sourceString
repeat with thisKey in sourceString
	set the end of endString to LookUpData(thisKey)
end repeat
set AppleScript's text item delimiters to {"-"}
set endString to endString as text

display alert endString
on LookUpData(key)
	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {key & tab}
	try
		set dataForKey to paragraph 1 of text item 2 of lookUpTable
	on error
		set dataForKey to ""
	end try

	set AppleScript's text item delimiters to oldDelims
	return dataForKey
end LookUpData
----------------------

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

I would store the values as a text file that is read at runtime.

HTH,

ES

 _______________________________________________
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: Bruce Robertson <email@hidden>
References: 
 >A Lookup Function? (From: Marconi <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 8, Issue 56
  • Next by Date: Re: A Lookup Function?
  • Previous by thread: A Lookup Function?
  • Next by thread: Re: A Lookup Function?
  • Index(es):
    • Date
    • Thread