Computer Science Canada

problem with char...please help thanks

Author:  rated [ Thu May 22, 2008 1:35 am ]
Post subject:  problem with char...please help thanks

Turing:

quizquestion1 := getchar
    if quizquestion1 = 'e' then
        menu
    elsif quizquestion1 not= chr(49) or quizquestion1 not= chr(50) or quizquestion1 not=chr(51) or quizquestion1 not=chr(52) then
            Font.Draw ("INVALID KEY ENTERED! PRESS E TO RETURN TO MAIN MENU ", maxx div 2 - 180, maxy div 2 - 220, font1, white)
end if


Im asking the user to press a character on the keyboard, and if they do not press 1, 2, 3, 4, they get the "invalid key entered". However, the problem is whenever i press 1 or 2 or 3 or 4 im still getting the "invalid key entered"

What is the problem?

thanks

Author:  Tony [ Thu May 22, 2008 2:23 am ]
Post subject:  RE:problem with char...please help thanks

I don't think that would even return to the "menu", it would just load the menu procedure within the existing procedure.... I suspect infinite recursion.

But anyway. If my quizquestion1 is '2' (so chr(50)), what does

quizquestion1 not= chr(49) or quizquestion1 not= chr(50) or quizquestion1 not=chr(51) or quizquestion1 not=chr(52)

evaluate to? and why?


: