View Single Post
  #13   Spotlight this post!  
Unread 07-02-2005, 14:59
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Syntax Problems...

Quote:
Originally Posted by Kevin Watson
What happens when counter == 240? I think you should be using a >= or <= in there someplace.
I was going to say "IN THIS CASE, I doubt that it would cause a problem." (Because I expected that the RC would just continue doing what had been doing for 1/40th of a second longer.) But then I looked at the "else" case, and saw that it would set the end_program flag, terminating the autonomous program.

I would prefer to fix this by doing something less error-prone like this:
Code:
			if(counter < 121) /* if less than 2 seconds have passed */
				{...}
			else if(counter < 240) /* if 2-4 seconds have passed */
				{...}
			else if(counter < 360) /* if 4-6 seconds have passed */
				{...}
			else if(counter < 480) /* if 6-8 seconds have passed */
				{...}
			else if(counter < 600) /* if 8-10 seconds have passed */
				{...}
			else if(counter < 720) /* if 10-12 seconds have passed */
				{...}
			else if(counter < 780) /* if 12-13 seconds have passed */
				{...}
			else if(counter < 900) /* if 13-15 seconds have passed */
				{...}
			else /* if more than 15 seconds have passed */
				{...}
			}
Quote:
(This bug bites me all the time <grin>).
Yeah, it's gotten me a few times too.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me