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

Username:   Password: 
 RegisterRegister   
 Operands of boolean operators must be boolean?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Armagedd0nn




PostPosted: Wed Nov 14, 2007 4:13 pm   Post subject: Operands of boolean operators must be boolean?

Im making a program and I have a section like this:

elsif word not= "Walk" or "Run" or "Stand Still" then
put "You must do something"

but it gives me this error: Operands of boolean operators must be boolean
I cannot figure out how to fix it. I am pretty new to turing so this question may be a bit sad to some I suppose but I really need help to fix this.

Thanks!
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Nov 14, 2007 4:24 pm   Post subject: RE:Operands of boolean operators must be boolean?

What are you comparing "Run" to? You need to explicitly re-state that you are comparing the value stored in word is not equal to each of those values.
Tony




PostPosted: Wed Nov 14, 2007 4:24 pm   Post subject: RE:Operands of boolean operators must be boolean?

boolean operators such as AND, OR operate only on boolean operands, meaning TRUE and FALSE.

String such as "Run" are not TRUE or FALSE, thus the error.

You are looking for something like
code:

elsif word not= "Walk" or word not= "Run" or word not= "Stand Still" then
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nick




PostPosted: Wed Nov 14, 2007 4:44 pm   Post subject: RE:Operands of boolean operators must be boolean?

close Tony but that code will always return true this is more what u want
code:
elsif word not= "Walk" and word not= "Run" and word not= "Stand Still" then
Tony




PostPosted: Wed Nov 14, 2007 4:46 pm   Post subject: RE:Operands of boolean operators must be boolean?

hey, faulty logic was not the part of the original question Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Armagedd0nn




PostPosted: Wed Nov 14, 2007 6:52 pm   Post subject: Re: Operands of boolean operators must be boolean?

Thank you for the quick help.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: