View unanswered posts | View active topics It is currently Mon Oct 20, 2014 4:11 am






Reply to topic  [ 5 posts ] 
Logic problems; possible bugs? 
Author Message
Rookie

Joined: Sat Sep 20, 2008 12:02 am
Posts: 11
Post Logic problems; possible bugs?
Hello,
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.


Thu Oct 30, 2008 9:35 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post 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?

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Thu Oct 30, 2008 10:02 pm
Profile
Rookie

Joined: Sat Sep 20, 2008 12:02 am
Posts: 11
Post 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.


Thu Oct 30, 2008 10:33 pm
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: Logic problems; possible bugs?
Michael,

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

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

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


Fri Oct 31, 2008 12:29 pm
Profile
Rookie

Joined: Sat Sep 20, 2008 12:02 am
Posts: 11
Post 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!


Fri Oct 31, 2008 5:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.