
Global versus Local Variables within Functions
Hello there! First time poster. I am playing around with creating functions in ROBOTC and have a couple of questions I was hoping the community could help answer. I didn't want to overload this one post though since each question is a little different, so I'm going to break it up into a few posts
I'm a bit confused how to navigate the difference between global and local variables in ROBOTC. Am I able to execute a function which uses global variables when I call the function? For example:
Or instead do I have to define a local variable within the function to pass along?
What would happen if I did the 2nd example, but declared the variable name "forwards" within the
moveforwards function instead of "forwards_temp"? Would I get a compile error because there are two different variables, one global and one local, being declared with the same name? Or would ROBOTC just take the move recent declaration/assignment as the final one?
Thanks for the help!