: Yeah, I’m sure I’ve seen this sort of thing before, I just can’t find
: anything about it now! I’ve tried doing it myself but haven’t been able to
: manage it yet. The only way I could think of was to create a list of the
: string lengths, then create a string of the list of strings, get the
: offset of the required string in this list and somehow, using the string
: lengths list, get the offset from there!? Maybe…
: Well, I know what I mean anyway!
: I may have another go at it…
: Cheers,
: Juerg
Eureka!
This getting-the-index technique only works if all the text strings in the subject list are the same length, which might apply for your error codes:
property theCodes : {"101", "102", "103"}
property theMsgs : {"I'm the message for error #101", "for error #102", "for 103"}
set theKey to text returned of (display dialog "Enter error code" default answer "")
set codeText to theCodes as text
set theIndex to (((offset of theKey in codeText) - 1) / 3) + 1
if theIndex is not less than 1 then
display dialog (item theIndex of theMsgs)
else
display dialog "Message not found"
end if
Marc K. Myers
Marc@AppleScriptsToGo.com
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[5/24/02 1:37:13 PM]