Re: A Lookup Function?
Re: A Lookup Function?
- Subject: Re: A Lookup Function?
- From: BareFeetWare <email@hidden>
- Date: Tue, 25 Jan 2011 05:53:05 +1100
On 25/01/2011, at 4: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?
> My lookup table would be:
>
> A Alpha
> B Bravo
> ...
> Z Zulu
> What's the most efficient way to store and initialize the table, and look up the values?
I'd do this:
on LookupInList(keyValue, keyColumn, listOfLists, lookupColumn)
repeat with thisList in listOfLists
if item keyColumn in thisList is keyValue then
set lookupValue to item lookupColumn in thisList
exit repeat
end if
end repeat
return lookupValue
end LookupInList
like this:
on run
set phoneticTable to {{"A", "Alpha"}, {"B", "Bravo"}, {"Z", "Zulu"}}
get LookupInList("B", 1, phoneticTable, 2)
end run
Tom
BareFeetWare
_______________________________________________
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