hello everyone,
I am new to this board and have a simple question. How do i impose that a user input an integer? I guess it’s best to explain with an example. Lets say I have this simple code
set n to missing value
display dialog "Please enter an integer:" default answer ""
try
set n to text returned of result as integer
end try
if n ≠missing value then
if n mod 2 = 0 then
display dialog "The number is even"
else
display dialog "The number is odd"
end if
else
display dialog "You didn't enter an integer"
end if
as you can see entering a value of 1.5 would be converted to 2 after the class “as integer” is executed. Hence the number would be read as even. How do I correct this?