Task

Write a game (computer program) that follows the following rules:

 The computer chooses a number between given set limits.
 The player is asked for repeated guesses until the the target number is guessed correctly
 At each guess, the computer responds with whether the guess is:
 higher than the target,
 equal to the target, 
 less than the target,   or
 the input was inappropriate. 


Related task

   Guess the number/With Feedback (Player)


command guessTheNumber lowN highN
    local tNumber, tguess, tmin, tmax
    if lowN is empty or lowN < 1 then
        put 1 into tmin
    else
        put lowN into tmin
    end if
    if highN is empty then 
        put 10 into tmax
    else
        put highN into tmax
    end if
    put random(tmax - tmin + 1) + tmin - 1 into tNumber
    repeat until tguess is tNumber
        ask question "Please enter a number between" && tmin && "and" && tmax titled "Guess the number"
        if it is not empty then
            put it into tguess
            if tguess is tNumber then 
                answer "Well guessed!"
            else if tguess < tNumber then 
                answer "too low"
            else  
                answer "too high"
            end if
        else
            exit repeat
        end if
    end repeat
end guessTheNumber