View Single Post
  #1   Spotlight this post!  
Unread 16-01-2006, 23:55
Matt Adams's Avatar
Matt Adams Matt Adams is offline
b(o_o)d
FRC #1525 (Warbots)
Team Role: Engineer
 
Join Date: Dec 2003
Rookie Year: 2000
Location: Arlington Hts. IL
Posts: 375
Matt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond repute
Send a message via AIM to Matt Adams
Re: Strange Problem, varible not subtracting?

I see 3 lines involved, minus comments:

enc_Right_Difference = 100 - Enc_Right_Count_Old;
enc_Right_Old_Count = 50;
Print enc_Right_Difference


So... basically this is saying

enc_Right Difference = 100 - enc_Right_Count_Old_Which_Isn't_Set_To_Anything_Ye t
Set enc_Right_Count_Old to 50
print enc_Right_Difference

I don't really see anything that suprises me. I think you wanted to do:

Set enc_Right_Count_Old to 50
enc_Right Difference = 100 - enc_Right_Count_Old
print enc_Right_Difference (which will be 50)

You need to set your variable enc_Right_Count_Old = 50 before you want to use math involving it, or it will just use zero (it doesn't know any better!). Move it to the line above the subtraction, it should work as expected.

To better visualize this, you can put print statements right before you do the math and right after the math, and you can see what the variables are set equal to. You happened to put them in places that give you (seemingly) unexpected results.

Hope this helps,

Matt

Last edited by Matt Adams : 17-01-2006 at 00:02.