View unanswered posts | View active topics It is currently Sun Oct 26, 2014 1:26 am






Reply to topic  [ 4 posts ] 
Why Aren't my Functions 
Author Message
Rookie

Joined: Tue Nov 20, 2012 9:14 pm
Posts: 2
Post Why Aren't my Functions
Hello!
I am new to RobotC but I have had plenty of other programming experience.

I Imagine that this problem is probably a silly mistake, but my functions can't be called. When the are called the compiler throws a error.

For Example, this code:
Code:
task main()
{
int thistest;
thistest = testing(thistest);


}

int testing(int ttetred)
{
   ttetred += 10;
   return ttetred;
}


Gives Me this compiler Message:
**Error**:Undefined procedure 'testing'.
**Error**:Too many parameters specified. Call to 'testing'. Parameter: 'N/A' is 'thistest' of type 'short'.

Every other Function I have tried gives my the same error.
Anyone Know Why?
Thanks!


Tue Nov 20, 2012 9:19 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Why Aren't my Functions
Any function must be declared before it is called. So if you switch the order of your task main and the function testing, it will get rid of the compiler error.
Code:
int testing(int ttetred)
{
   ttetred += 10;
   return ttetred;
}

task main()
{
  int thistest;
  thistest = testing(thistest);
}


Tue Nov 20, 2012 9:43 pm
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: Why Aren't my Functions
In C, You have to declare before writing, same with variables.

_________________
string Robored = "Awesome"
~~Neil Balch~~


Wed Nov 21, 2012 12:43 am
Profile WWW
Rookie

Joined: Tue Nov 20, 2012 9:14 pm
Posts: 2
Post Re: Why Aren't my Functions
Thanks! I don't know C so I wouldn't have figured that out.


Sat Nov 24, 2012 12:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.