Go to Post Why is it considered shameful to do the smart thing? As the saying goes, "I don't make the rules, I just live by them." - Chris Hibner [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-24-2010, 12:35 PM
DWirth DWirth is offline
Registered User
FRC #2509
 
Join Date: Feb 2009
Location: Hutch
Posts: 10
DWirth is an unknown quantity at this point
Joystick Button Controlling Relay

Hello,
I'm having problems with the code I have written. Every time I compile the .cpp file it tells me:
'If' undeclared (first use of the function)
'Else' undeclared (first use of the function)
I think this means that the if and else statement do not know what they are controlling. Please correct me if I'm wrong. This is my code below:

Code:
{
				If(stick->GetRawButton(1));
					relay1->Set(Relay::kForward); // run line when button is pressed
				Else;
					relay1->Set(Relay::kOff); // or run this line when button isn't pressed
			}
Reply With Quote
  #2   Spotlight this post!  
Unread 04-24-2010, 12:52 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,547
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Joystick Button Controlling Relay

if and else should all be lowercase, they are reserved words.

You also shouldn't have a semicolon after the if or the else http://www.cprogramming.com/tutorial/lesson2_tg.html
Reply With Quote
  #3   Spotlight this post!  
Unread 04-24-2010, 01:03 PM
DWirth DWirth is offline
Registered User
FRC #2509
 
Join Date: Feb 2009
Location: Hutch
Posts: 10
DWirth is an unknown quantity at this point
Re: Joystick Button Controlling Relay

Perfect, thanks for the advice and resources. Seemed to have solved the issue.
Reply With Quote
Reply


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
Controlling the camera with a joystick Dakabt Programming 9 02-01-2010 09:51 PM
Joystick Button Issues pyr0b0y NI LabVIEW 6 04-21-2009 09:29 AM
joystick button furiousgeorge Programming 5 02-07-2009 03:57 PM
How do I program a relay to turn on and off by pressing a button on the joystick? eweathers NI LabVIEW 4 01-28-2009 10:34 PM
Speed controlling a relay..?!?!?one/???? Monochron Programming 13 02-17-2007 09:43 PM


All times are GMT -5. The time now is 10:40 AM.

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