Thread: While loops
View Single Post
  #3   Spotlight this post!  
Unread 01-11-2006, 06:55
Timothy D. Ginn's Avatar
Timothy D. Ginn Timothy D. Ginn is offline
I check here maybe once a year.
no team
 
Join Date: Apr 2003
Rookie Year: 2002
Location: Port Perry, ON. Canada
Posts: 247
Timothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to all
Send a message via ICQ to Timothy D. Ginn Send a message via AIM to Timothy D. Ginn Send a message via MSN to Timothy D. Ginn Send a message via Yahoo to Timothy D. Ginn
Re: While loops

This really depends on what the while loop does. If it's say, something to the effect of:

Code:
int i = 0;
while(i < 10) {
  i++;
}
then certainly you can do it. If, instead you're doing something relying on external sensors/states. For example, in pseudo code:

Code:
while(button is pushed) {
  do stuff
}
then you won't get anywhere because whether or not the button is pushed isn't going to be updated within your function (that updating in some of the FIRST-provided code which you don't need to and shouldn't modify; but, if you're curious you can look). If your code doesn't let the program flow continue to the FIRST-code which updates buttons you just won't have the new status of the button being pushed (and as a result you'll be stuck).

It's probably worth noting that your user code is already in a big while loop (the one you rightly pointed out is in the main function) and as a result already will be called repetitively.
__________________
Alumni of FRC Team 1006
Former mentor of Full Lego Alchemist (FLL 5621) - Sempar School / Computing Students' Association of Queen's University
Reply With Quote