Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Joystick Button Controlling Relay (http://www.chiefdelphi.com/forums/showthread.php?t=85500)

DWirth 24-04-2010 12:35

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
                        }


Joe Ross 24-04-2010 12:52

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

DWirth 24-04-2010 13:03

Re: Joystick Button Controlling Relay
 
Perfect, thanks for the advice and resources. Seemed to have solved the issue.


All times are GMT -5. The time now is 13:49.

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