my answer on your second question is NO. You have filter the input yourself. Here, comes the answer on your first question. One way I know is this:
set theChars to characters of "(๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧"
repeat
display dialog "type whatever key you want, except for some (๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧" default answer ""
set the keyTyped to the text returned of the result
set goodInput to true
repeat with aChar in theChars
if keyTyped contains aChar then
set goodInput to false
exit repeat
end if
end repeat
if goodInput then exit repeat
display dialog "Bad input. Try again, or cancel."
end repeat
set theChars to characters of "(๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧"
repeat
display dialog "type whatever key you want, except for some (๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧" default answer ""
set the keyTyped to the text returned of the result
set goodInput to true
repeat with aChar in theChars
if keyTyped contains aChar then
set goodInput to false
exit repeat
end if
end repeat
if goodInput and (length of keyTyped > 1) then exit repeat
display dialog "BAD INPUT FOUNDED:
Not acceptable character(s), OR
the length of the text is less than 2.
Try again, or cancel."
end repeat
OR, little more effective:
set theChars to characters of "(๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧"
repeat
display dialog "type whatever key you want, except for some (๑ ऀืົཽ₍₍ළ₎₎ ऀืົཽ)✧" default answer ""
set the keyTyped to the text returned of the result
set goodInput to true
repeat with aChar in theChars
if (length of keyTyped < 2) or (keyTyped contains aChar) then
set goodInput to false
exit repeat
end if
end repeat
if goodInput then exit repeat
display dialog "BAD INPUT FOUNDED:
Not acceptable character(s), OR
the length of the text is less than 2.
Try again, or cancel."
end repeat
NOTE: maybe, I don’t understood you, and you want accept combination of not acceptable characters in the input, but not single not acceptable characters in the input. If this is true, then you should just replace contains with is (in the my first suggestion).
I also wasn’t sure what the OP wanted. I thought he might want to report an error when a prohibited character is a separate word (i.e. spaces before and after).
set ATID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set theString to text items of "a table" -- error due to prohibited word "a"
--set theString to text items of "r table" -- no error
set theChars to {"a", "b", "c", "d"} -- prohibited characters
repeat with anItem in theString
if (count anItem) = 1 and anItem is in theChars then
display dialog "Erroneous character found" buttons "OK" cancel button 1 default button 1
end if
end repeat
set AppleScript's text item delimiters to ATID
I really appreciate both of your responses!
I managed to do what I needed with a combination of your answers, plus gain some more robust knowledge of AppleScript. For that, I’m grateful and I will be more thoughtful next time in being more clear in my questions.