Re: A Lookup Function?
Re: A Lookup Function?
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