Thread: Variable Scope
View Single Post
  #1   Spotlight this post!  
Unread 10-02-2007, 14:06
billdar billdar is offline
Registered User
FRC #2085
 
Join Date: Jan 2007
Location: california
Posts: 3
billdar is an unknown quantity at this point
Variable Scope

I know its pretty late asking these questions, but we haven't gotten
to building a competition port dongle yet and I have a nagging question
on variable scope within the 3 WPI functions (Initialize, Autonomous,
Operator).

The kids have been practicing with code laid out like this:
main()
{
int someVariable;
while (1)
{
doSomethingTo(someVariable);
}
}
And they have been assuming that someVariable will retain its
value each time it loops.

Two questions on this, if they write the same kind of code in either
the Autonomous() or OperatorControl() functions:
- Will the forever loops break the background competition port monitoring
task?
- How do I define a variable that retains its value when Autonomous()
or OperatorControl() loops?
Thanks,

-Bill
Team 2085