set repeatedTimes to 0
set secondDialog to (display dialog "how many times?" default answer " ")
set answer to text returned of secondDialog
repeat until repeatedTimes = answer
display dialog answer
display dialog repeatedTimes
set repeatedTimes to repeatedTimes + 1
end repeat
i used the display dialog answer and display dialog repeatedTimes to check to see if they were equal, and they were, but the script continued repeating
also,
set answer to 1
set repeatedTimes to 1
display dialog answer & repeatedTimes
won’t work so i had to do them separately, is there any way to have two variables in one display dialog?
You have had coercion issues. That means that your problems have been that you have used incompatible datatypes, in your first example, the answer is of type text, so that it can never be equal to repeatedTimes, and therefore you’ll never break out of the loop.
set repeatedTimes to 0
set secondDialog to (display dialog "how many times?" default answer " ")
set answer to text returned of secondDialog as integer
--We need to coerce the answer to an integer, so that 2 integers are compared below.
repeat until repeatedTimes = answer
display dialog answer
display dialog repeatedTimes
set repeatedTimes to repeatedTimes + 1
end repeat
Your problem in the second example is that the display dialog really are supposed to return text, in your case, it tries to coerce two integers and that fails, now, if you had put a text in front in the concatenation, like (“”&num1&num2) then it would have worked. I chose to just coerce it the most readable way.
set answer to 1
set repeatedTimes to 1
display dialog (answer & repeatedTimes) as text