–This is very similar to my previous post but easier to follow. Please copy this into a new script window and enter “ab” into the dialog box.
set CorrectEntrySet to {“ab”, “cd”}
set EntryDialogDisplay to display dialog “My Selection” buttons {“OK”} default button “OK” default answer “”
set EnteredLetters to text returned of EntryDialogDisplay
if EnteredLetters is in CorrectEntrySet then
beep
end if
get EnteredLetters
–Even if you enter “ab” or “cd” you will not get a beep, even though the result window shows EnteredLetters to be what you entered. However, if you change
–
–to
–<if “ab” is in CorrectEntrySet>
–of course you get a beep. But in the first case EnteredLetters was “ab”. I truly can`t figure this out. Please help me out.
–Bruce Whitred
–Follow Your Dreams
–P.S. This was compiled using AppleScript
You are running Panther, true?
You sample code works fine for me. However, I’ve found some problems with text returned from dialogs, and some stuff working in the past now throw errors.
I’m not sure, but I’d say that in versions previous, at least, to AS 1.9.3 text returned from dialogs was not Unicode text, but plain strings. Probably something related to the new changes to the “display dialog” command.
Try adding this line before the “if” block:
set EnteredLetters to «class ktxt» of (EnteredLetters as record)
Or, if you need Unicode data to play with:
set CorrectEntrySet to {"ab" as Unicode text, "cd" as Unicode text}
I’m not a expert in Unicode stuff, but I think that “ktxt” is the “text” itself (two-byte) and “ksty” is the style information. You can see the only difference if we compare our ksty data is the “font-family id” (mine is “0003”, most probably “Geneva”; yours is “4000”, ?)
Traditionally, we use the “as record” trick to extract “plain text” (called “string” in AppleScript) from text with extra information (such as “International text” -contains script code and language-, “styled text” -contains style data, such as bolds and colors- or “Unicode text” -doublebyte text, plus style data).