A better solution would be to use a SenableChooser. The following is for command based but sendable chooser uses void* so the sky is the limit as to what you send. You can send a command, number, or some other pointer.
Code:
class Robot : public IterativeRobot
{
private:
SendableChooser* autoChooser;
void RobotInit {
autoChooser = new SendableChoose();
autoChooser->AddDefault("Auto 1", new Auto1Command());
autoChooser->AddObject("Auto 2", new Auto2Command());
autoChooser->AddObject("Auto 3", new Auto3Command());
SmartDashboard::PutData"Auto Chooser", autoChooser;
}
void AutonomousInit() {
Command* auton = (Command*)autoChooser->GetSelected();
if (auton) {
auto->Start();
}
}
void TeleopInit() {
if (auton) {
auto->Cancel();
}
}
};
There is more documentation here.
http://wpilib.screenstepslive.com/s/...smartdashboard