Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 problem with char...please help thanks
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rated




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: