Go to Post Besides, you know hard it is to solder with gloves on? - Al Skierkiewicz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 18-02-2007, 11:50
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Looping a function

Are you absolutely sure that the function is working properly? If it was executed once from Process_Data_From_Master_uP, and isn't in an if statement or other structure, it is probably getting executed again (especially if you are printing results from it).

Check the function to make sure that it is using the right inputs, and that it is definetely USING them. I've had this problem before, and without fail it is because I used the wrong variable, or in one of the lines of the function, I didn't use the result from the previous line. You could also post the code and let us look at it. I wouldn't worry about people stealing it. After all, it is broken

Another possibility is that you have scope problems. Code like this could cause issues like you are seeing:
Code:
// Bongle's error in scoping example
int degrees = 5;
printf("%d,%d,%d",servo,tilt,other) // verifies all the inputs are changing
if(someCondition)
{
   int degrees; // creates a variable that shares name with another variable in the code
   degrees = myCustomFunction(); // calls the function, assigns it to the most-local variable (the one we just declared)
}                   // at this closing brace, the degrees variable that stored our result is destroyed
printf("%d",degrees) // always prints out a constant value, despite inputs always changing
Your output will never change (it will always print 5) because the assignment statement in the if statement assigns the return value to a variable that shortly afterwards is destroyed at the end of the if statement.

Last edited by Bongle : 18-02-2007 at 11:54.
 


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
Arcade Function gabrielse Programming 1 08-02-2006 00:49
Autocalibrate function Validius Programming 2 29-03-2005 21:59
Looping Atonomous BobcatProgramer Programming 2 24-02-2004 14:06
FreeLibrary() Function Raven_Writer Programming 0 09-08-2003 15:39
control program looping??? ctartist236 Programming 1 08-02-2002 10:09


All times are GMT -5. The time now is 02:58.

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