Computer Science Canada

Operands of boolean operators must be boolean?

Author:  Armagedd0nn [ 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!

Author:  Clayton [ 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.

Author:  Tony [ 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

Author:  Nick [ 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

Author:  Tony [ 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

Author:  Armagedd0nn [ Wed Nov 14, 2007 6:52 pm ]
Post subject:  Re: Operands of boolean operators must be boolean?

Thank you for the quick help.


: