Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   FIRST Tech Challenge (http://www.chiefdelphi.com/forums/forumdisplay.php?f=146)
-   -   [FTC]: Top Hat coding problem (http://www.chiefdelphi.com/forums/showthread.php?t=72683)

nate15810 22-01-2009 16:53

[FTC]: Top Hat coding problem
 
ok yet another coding problem for me.

this is my problem:

Code:

if (joystick.joy2_TopHat = 0)
    {
      servo[ServoB] = 20;
    }
    else
    {
      servo[ServoB] = 255;
    }

this won't work, nor will
Code:

if (joy2_TopHat = 0)
i need the top hat button to activate servos, but nothing is working
contacted patrick, but it still doesn't work...he's studying and i don't want to bother him anymore haha

ttldomination 22-01-2009 17:23

Re: [FTC]: Top Hat coding problem
 
Your problem is just an syntax error.

The sign "=" is an assignment operator where the sign "==" is the comparison operator. So you would have to do...

if(joystick.joy2_TopHat == 0)
{
code goes here
}

nate15810 22-01-2009 18:03

Re: [FTC]: Top Hat coding problem
 
thanks it works

Rick TYler 23-01-2009 18:20

Re: [FTC]: Top Hat coding problem
 
Quote:

Originally Posted by nate15810 (Post 806083)
thanks it works

Ask me how long it took me to remember that "or" in C is really "||". Some of us haven't programmed in C in a L-O-N-G time. :)

ttldomination 23-01-2009 19:47

Re: [FTC]: Top Hat coding problem
 
I have never programmed in C before. I picked up the basic syntax from java and I just needed to learn the functions for this year.

The syntax is amazingly similar.

Rick TYler 23-01-2009 22:33

Re: [FTC]: Top Hat coding problem
 
Quote:

Originally Posted by ttldomination (Post 806808)
The syntax is amazingly similar.

The secret of software development is that structures replicate a lot across languages, but the language programmers randomly change syntax. You will eventually find yourself thinking, "OK, how do I do recursive functions in this <blank blank> language." You know the structures are there somewhere -- you just need to decipher how to make it work in THIS language. Using "&&" instead of "and," for example, is just an arbitrary choice from the dim past. YMMV.


All times are GMT -5. The time now is 18:03.

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