@briancole .. However, we are worried that when the competition template switches from driver to auton, it clears integers, which would ruin our auton. Does anyone know if this is true?
It's difficult to answer your question briefly, or without sounding like a programming snob. I'm not trying to demean your knowledge; asking questions is how we all learn. I'll try to be brief, but if you've read any of my posts, you know I can't really do that. And I can't avoid saying "hypothetical" sometimes, either.
Between autonomous and drive tasks, nothing is really "cleared," however variables not in scope are just that: not in scope. Which means they can't be seen. The fact that they are integer ("int") type has nothing to do with it.
If you declare a variable inside a set of curly braces, whether those braces are the highest level ones of a task, or inside a while loop, or in one branch of an if statement, then no code outside those curly braces can see the variables. You can also cover up an existing variable by declaring a new instance of the same name inside an internal block of code demarked by curly braces. The outer scoped variable still exists, but the code inside the inner block can't see it.
A practical answer:
You have two easy choices:
- Declare variables you want to be seen in multiple scopes in the source file outside of any block of code. Right after the pragmas, for instance. These are global variables, and will be visible in every inner scope. (Unless the name is "covered" in the inner scope by a new definition using the same name. Don't do that and you're fine.)
- Create a function that you can call from within any task or function. (Function names in C exist in a global scope.) Inside your function, declare the variables that contain your recorded autonomous routine. Call the function whenever you want to use the recorded values.