View Single Post
  #10   Spotlight this post!  
Unread 24-03-2004, 12:51
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: What is wrong with this code???? It won't Compile and I don't know why? Please He

Quote:
Originally Posted by Alan Anderson
Oh, my. There's certainly something odd going on:
Code:
case DR_BOTH_CENTER:
{
    Navigator_State = AT_TARGET; // Both servos are within the target threshold
    printf("AT_TARGET\n");
    break;
}
}
}
    else
    {
        // We are not locked on - Stop
        // give the trackers a chance to catch up
        left_drive_set = LSTOP;
        right_drive_set = RSTOP;
        drive_timer++ ;
        if (drive_timer > LOST_TARGET_TIMEOUT) 
        {
            Navigator_State = TURN_TO_TARGET;
            printf("TURN_TO_TARGET\n"); // Done driving to center
            left_servo_set = 127;
            right_servo_set = 127;
        }
    }
    break;
}
There are three }s in a row right before a naked else statement. This source code is apparently missing a few lines, including an if.

There is also a case statement commented out near the top of the big switch. That can't be doing what you want, can it? If you want to "skip" that state, as the comments suggest, I think you need to initialize your state variable to DRIVE_TO_CENTER instead of WAIT_TO_DRIVE in line 37.
I believe the three braces are OK. If you move your cursor in turn to each of those braces and type Ctrl-M, the editor will take you to their matching opening braces. They look fine to me.

As to the commented out case label, THAT does look strange, but I highly doubt that would cause the compile error in question. I don't know what the compiler will do with a chunk of code inside a switch statement without a case label. My guess is that it will simply be unreachable.
__________________
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