Syntax error

Here’s the code

	
	WPI_VictorSPX rightDrive =  new WPI_VictorSPX(1);
	WPI_VictorSPX leftDrive =  new WPI_VictorSPX(2);
	DifferentialDrive driveTrain = new DifferentialDrive(leftDrive, rightDrive);

	WPI_VictorSPX rightDriveSlave =  new WPI_VictorSPX(3);
	WPI_VictorSPX leftDriveSlave =  new WPI_VictorSPX(4);
	
	rightDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
	leftDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
	
	rightDriveSlave.set(rightDrive.getDeviceID());
	leftDriveSlave.set(leftDrive.getDeviceID());

	
	rightDriveSlave.follow(rightDrive);
	leftDriveSlave.follow(leftDrive);
	

What’s erroring? What messages are you seeing? What have you done to mitigate the issue? Do you have any theories about what’s going wrong?

Everything that you’ve provided is hopelessly vague. We can’t help you unless you decide you’re willing to help us out a bit.

it says

ultiple markers at this line
	- Syntax error on token ";", @ expected
	- Syntax error on token ".", @ expected after 
	 this token

I have changed the punctuation and the syntax but doesn’t work

Which line?

All the slaves one

rightDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
	leftDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
	
	rightDriveSlave.set(rightDrive.getDeviceID());
	leftDriveSlave.set(leftDrive.getDeviceID());

	
	rightDriveSlave.follow(rightDrive);
	leftDriveSlave.follow(leftDrive);

all of this

Something to try: starting at the bottom line, comment out one line at a time until the error disappears. Sometimes a syntax error at a higher line will confuse the compiler and it’ll report an error on line(s) below the actual error.

Didn’t work

Is your team programming in Java or C++? You’ve posted to the Java forum, so I have to think that its Java. But the languages are so similar syntactically that your code snippet could almost be C++ (almost; which would explain the syntax error). If Java, I don’t see any errors.

Unfortunately, you have not included the errors that your compiler output to the console for us to see, so potential helpers are left to guess. The best advice I can offer is to let us see what you see, so that the CD community can be of more assistance.

I suspect that your code looks like this:


public class ClassName {

  WPI_VictorSPX rightDrive =  new WPI_VictorSPX(1);
  WPI_VictorSPX leftDrive =  new WPI_VictorSPX(2);
  DifferentialDrive driveTrain = new DifferentialDrive(leftDrive, rightDrive);

  WPI_VictorSPX rightDriveSlave =  new WPI_VictorSPX(3);
  WPI_VictorSPX leftDriveSlave =  new WPI_VictorSPX(4);
	
  rightDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
  leftDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
	
  rightDriveSlave.set(rightDrive.getDeviceID());
  leftDriveSlave.set(leftDrive.getDeviceID());

	
  rightDriveSlave.follow(rightDrive);
  leftDriveSlave.follow(leftDrive);

}

Methods cannot be called from the base level in a class. They can only be called in constructors or methods. You should move those calls to an initialize() method


public class ClassName {

	
  WPI_VictorSPX rightDrive =  new WPI_VictorSPX(1);
  WPI_VictorSPX leftDrive =  new WPI_VictorSPX(2);
  DifferentialDrive driveTrain = new DifferentialDrive(leftDrive, rightDrive);

  WPI_VictorSPX rightDriveSlave =  new WPI_VictorSPX(3);
  WPI_VictorSPX leftDriveSlave =  new WPI_VictorSPX(4);

  public void initialize() {

    rightDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);
    leftDriveSlave.changeControlMode(WPI_VictorSPX.VictorControlMode.Follower);

    rightDriveSlave.set(rightDrive.getDeviceID());
    leftDriveSlave.set(leftDrive.getDeviceID());
    rightDriveSlave.follow(rightDrive);
    leftDriveSlave.follow(leftDrive);
  }
}

Again, this is only a guess. We can’t know for certain without being able to see your code