Repeat While statement with OR (two different comparisons)?

Any experienced coder will know the answer to this, but I can’t find it spelled out clearly so I am asking for help.

I am trying to write a script with an a “repeat while” statement that should look something like this:

repeat while (count characters of changeToName) is greater than 31 or equal to 0

I display a dialog in which I ask the user to enter a filename no longer than 31 characters, and I can easily redisplay the dialog if the user enters a filename with 32 or more characters. But I also want to redisplay the dialog if the user leaves the input box blank.

Is there an obvious way to do this that I’m missing?

Thanks for any help.

Hi,

both terms must be evaluated separately


repeat while ((count characters of changeToName) = 0 or (count characters of changeToName) > 31)

or to avoid counting the characters twice


repeat
	tell (count characters of changeToName) to if it = 0 or it > 31 then exit repeat
	-- do something
end repeat

Thank you for this. I’ve learned two things - how to do this double comparison, and how to do that extremely elegant comparison in the second version. (Unfortunately, the second version does not seem to work when I test it. Is the syntax perfectly correct?)

sorry, the second version must be the other way round and the boolean operand must be and


repeat
	tell (count characters of changeToName) to if it > 0 and it < 32 then exit repeat
	-- do something
end repeat

I was writing a post suggesting the change from “or” to “and”, but you go there first. That works perfectly, and is very, very elegant. Thank you again!