View Single Post
  #4   Spotlight this post!  
Unread 15-02-2008, 19:49
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,562
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: This code will NOT compile

I noticed a few more errors in your functions.

Code:
int square2 (p2_y);
{
return p2_y * p2_y
}
If you want it to take a variable you pass, you need to declare the type of variable. Also, you shouldn't have a semicolon on the end of the declaration but should on the return statement. p2_y is a global variable, so it's not wise to also use it as a local variable (I don't think it will cause a compile error, but it is confusing to read).

If you want separate functions for each joystick axis, you could write it like:
Code:
int square2 ()
{
return (p2_y * p2_y);
}
For a generic function, you could write

Code:
int square2 (int variable_to_square)
{
return (variable_to_square * variable_to_square);
}



Note: It's much easier to help if you tell us what the error message is and what code is causing it.