Go to Post Mentoring is HARD. - Akash Rastogi [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2009, 13:45
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Using Integer variables

Can anyone show me an example of how to setup an integer variable in the BuiltinDefaultCode example?
__________________
"I would love to change the world but no one will give me the source code"
  #2   Spotlight this post!  
Unread 13-02-2009, 13:55
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Using Integer variables

In general, it's as easy as saying
Code:
int varname;
replacing varname with the name you want to use. The proper place to put that line depends on what you want to use the variable for.

What do you want to use the variable for?
  #3   Spotlight this post!  
Unread 14-02-2009, 13:07
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
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.
__________________
"I would love to change the world but no one will give me the source code"
  #4   Spotlight this post!  
Unread 14-02-2009, 17:00
Sentient's Avatar
Sentient Sentient is offline
Registered User
FRC #0639 (Code Red)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Ithaca
Posts: 21
Sentient is on a distinguished road
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.
  #5   Spotlight this post!  
Unread 14-02-2009, 17:26
Rick Wagner's Avatar
Rick Wagner Rick Wagner is offline
Registered User
FRC #3008 (Kalani Robotics)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Honolulu, Hawaii
Posts: 188
Rick Wagner is a splendid one to beholdRick Wagner is a splendid one to beholdRick Wagner is a splendid one to beholdRick Wagner is a splendid one to beholdRick Wagner is a splendid one to beholdRick Wagner is a splendid one to beholdRick Wagner is a splendid one to behold
Re: Using Integer variables

Quote:
Originally Posted by programmr View Post
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.
I think you want to be saying

Code:
if (x == 1) { ...
rather than the single equal sign, which is an assignment operator, not a conditional.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying a 16 bit integer on PIC 16F877? Ian Curtis Programming 4 20-06-2008 15:42
integer print not making any sense. windell747 Programming 2 14-02-2008 23:32
integer division ImmortalAres Programming 5 11-07-2005 21:19
Integer Number powercat Programming 2 18-02-2003 11:26


All times are GMT -5. The time now is 11:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi