Logic problems; possible bugs?
Page 1 of 1

Author:  michael714 [ Thu Oct 30, 2008 9:35 pm ]
Post subject:  Logic problems; possible bugs?

We are running into some weird coding problems. We are using a boolean variable (bool) to trigger if-thens and while loops. We have a function where we set a variable to true after pressing a button on the Vex transmitter. In the debugger window, we are monitoring the value of the variable continuously. When we press the button, we can see that the variable is set to true. However, when we run the code (or step through the code), the if-then does not seem to believe that the variable is true. In fact, if we change the if-then to respond to false, it does so. So, it seems like the variable is set to true, but the if-then believes it is false.

We've run into this sort of illogical logic several times already and we usually just find some kind of workaround to deal with the situation (like using an integer instead of bool or testing for the opposite of what we expect). Is anyone else running into problems like this? If not, can we upload a ZIP file with the source code for somebody to look at?

Any thoughts would be appreciated.

Author:  jbflot [ Thu Oct 30, 2008 10:02 pm ]
Post subject:  Re: Logic problems; possible bugs?

I've been using ROBOTC for IFI quite a bit lately, including bool variables. I haven't run into this kind of problem, but I'd be happy to take a look at your code. You can post a zip file, or just copy-paste it in.

On a side note, what version of ROBOTC are you using?

Author:  michael714 [ Thu Oct 30, 2008 10:33 pm ]
Post subject:  Re: Logic problems; possible bugs?

For the Vex, we are using 1.40. I will post the zipped file tomorrow. Thank you for your offer of assistance.

Author:  AvidProgrammer [ Fri Oct 31, 2008 12:29 pm ]
Post subject:  Re: Logic problems; possible bugs?


In your if statements, are you explicitly checking for true? In other words, does your code look like either of these:
if (bMyVar == true) ....
if ((someVar < limit) == true) ....

If so, take out the explicit check to make the code look like this:
if (bMyVar) ....
if (someVar < limit) ....

The first method, where you explicitly check for 'true' is highly discouraged in RobotC.

Author:  michael714 [ Fri Oct 31, 2008 5:47 pm ]
Post subject:  Re: Logic problems; possible bugs?

I think you hit it on the head. We are explicitly checking for true. We'll try your suggestion. Thank you!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group