![]() |
Passing in variables into a command via command group
Hello people of the world! Its me again, with another question pertaining to programming. So I am having trouble figuring out how to pass an argument into a command in a Command Group. I don't know if it a formatting thing within the command itself or if I am doing something else wrong. What I mean by passing the argument is say I have addSequential(new AutoDrive()); and I want to pass in a speed for the different times that I want to call it. So in turn i would say addSequential(new AutoDrive(.5)); or AutoDrive(1) or something like that. Anyone know how to do this?
|
Re: Passing in variables into a command via command group
Quote:
|
Re: Passing in variables into a command via command group
Code:
package org.usfirst.frc2557.SOTABots2015.commands;Code:
package org.usfirst.frc2557.SOTABots2015.commands; |
Re: Passing in variables into a command via command group
Could you do me a favor and paste that code into code tags? To do this place a [/code] after the code and a [code] before it.
Thanks. |
Re: Passing in variables into a command via command group
Done.
|
Re: Passing in variables into a command via command group
Am I correct in assuming this is an issue of it just not working, not an issue of a compilation error?
|
Re: Passing in variables into a command via command group
Yes.
|
Re: Passing in variables into a command via command group
Quote:
First, you have done a good job of passing the value into the AutoDrive command. Now that it is in the command you need to actually do something with it. First off, we need a global place to store it so it is accessible out side of the constructor. I would also suggest naming the parameter something meaningful like power, or drivePower. It will make your code more readable in the future when you go back to it. Code:
private double power;Code:
private double power;Your execute() should look like this: Code:
protected void execute() {Code:
protected boolean isFinished() { |
Re: Passing in variables into a command via command group
Thank you very much! I guess I had a placement problem with my variable and where i was instantiating something. But anyways, thank you :)
|
| All times are GMT -5. The time now is 22:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi