set lookupTable to "
-------------------------------------------------------------
Christopher Stone, ;(123) 456-78910
James Dean, ;(098) 765-4321
-------------------------------------------------------------
"
set lookupTable to quoted form of lookupTable
set tableQuery to do shell script "egrep -io \"^[^-,]+\" <<< " & lookupTable
set AppleScript's text item delimiters to "|"
set tableQuery to text items of tableQuery
set AppleScript's text item delimiters to ""
set tableQuery to tableQuery as text
set AppleScript's text item delimiters to return
set tableQuery to text items of tableQuery
set tableQuery to choose from list tableQuery
if tableQuery ≠ false then
set tableQuery to tableQuery as text
set dialNumber to do shell script "egrep " & quoted form of tableQuery & " <<< " & lookupTable
set AppleScript's text item delimiters to ";"
set dialNumber to last text item of dialNumber
end if
This is very quick and dirty and is much easier using the Satimage.osax (or shelling out to Perl, Ruby, or Python). Nevertheless you can do it with pure Applescript.
I usually assign my lookup table a global or app-specific keyboard shortcut, so I can open and edit it with ease.
In the case of a script similar to the above I'll 'read' the text file rather than embed it in the script (unless the lookup table is very static).