![]() |
Using Integer variables
Can anyone show me an example of how to setup an integer variable in the BuiltinDefaultCode example?
|
Re: Using Integer variables
In general, it's as easy as saying
Code:
int varname;What do you want to use the variable for? |
Re: Using Integer variables
yes, where to put the variable seems to be our problem. we want to use the variable to keep track of the state of one of our joystick buttons in teleop mode.
int x; //Now later in the program during teleop routines if (rightStick->GetRawButton(2)) { if x = 1 { x=0; } else { x=1; } x could then be examined to determine the speed of our motors. |
Re: Using Integer variables
Where to put x is called scope. If you want x available throughout teleop mode (but you don't need it anywhere else), you can put it directly after OperatorControl(){
You may want to do some more research into scope though. It is an important concept to master. |
Re: Using Integer variables
Quote:
Code:
if (x == 1) { ... |
| All times are GMT -5. The time now is 02:27. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi