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