Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   !HELP! IM STUCK IN A SUBROUTINE!!! !HELP! (http://www.chiefdelphi.com/forums/showthread.php?t=49759)

Dave Scheck 02-11-2006 23:06

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
I agree with Alan and James that a problem exists in the use of the assignment operator, but the initial problem stated that the code was stuck in Left. I don't see how this could be reached. How was it determined that it was getting stuck in Left?

cdennisxlx2 03-11-2006 02:25

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
i had a student telling me what directions the wheels were turning and i took his word for it instead of double checking, but thank you all for the help

Matt Krass 03-11-2006 09:25

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
I still think we need to see the rest of the code, or at least how the time variable is defined. If it isn't defined static, the variable will be re-initialized everytime its host entity is restarted. So if it's at the top of your function, and this function runs over and over every loop, it will be reinitialized every loop to 0, no matter how much you increment it. Or, time can be a global and it will retain its value, but if you're assigning 0 to it every loop that will also ruin your day. I think you have a pretty simple (and somewhat hard to notice) problem that I'm unfortunately very familiar with, as Mark McLeod can tell you, how many times did I hit Chris with the robot again? ;)

cdennisxlx2 03-11-2006 15:28

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
the .c file is attached above, but i know for a fact thats not the problem because ive defined "time" and incrimented it the same way for 3 years now and i have had no problem with that at all.

Dave Flowerday 03-11-2006 15:50

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
Quote:

Originally Posted by Matt Krass
I still think we need to see the rest of the code, or at least how the time variable is defined. If it isn't defined static, the variable will be re-initialized everytime its host entity is restarted.

It's there, line 25 of user_routines_fast.c, as a global, so it should be fine. I'm not exactly sure what you mean by "If it isn't defined static, the variable will be re-initialized everytime its host entity is restarted."

Alan Anderson 03-11-2006 15:57

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
Quote:

Originally Posted by ghhs_1527
...ive defined "time" and incrimented it the same way for 3 years now and i have had no problem with that at all.

You probably have had problems, but you didn't recognize them as being caused by the way you're initializing your time variable. The way you're doing it, the initialization happens once when the robot powers up. You won't be able to rerun the autonomous mode correctly unless you reset the robot first. Better would be set time to zero explicitly when you enter the User_Autonomous_Code() function, just before the while (autonomous_mode) loop.

Matt Krass 03-11-2006 17:15

Re: !HELP! IM STUCK IN A SUBROUTINE!!! !HELP!
 
Quote:

Originally Posted by Dave Flowerday
It's there, line 25 of user_routines_fast.c, as a global, so it should be fine. I'm not exactly sure what you mean by "If it isn't defined static, the variable will be re-initialized everytime its host entity is restarted."

I missed the attached posting, my fault for trying to do too much at once, sorry about that.

As far as what I meant, I meant that a local variable inside of a function would be reset everytime the function ended and started again. Not sure why I worded it that way, let me just chalk it up to a goofy morning eh? :)


All times are GMT -5. The time now is 23:32.

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