[NXC] How to keep a variable "alive" in a subroutine
Posted: 20 Dec 2011, 20:20
Hi - I'm revisiting an old project and I'm still stumped on the same problem....
I have a string variable in a subroutine. Lets call it "x".
This subroutine calls another subroutine , on occasions, and that "called" subroutine needs to use the string "x" value from it's parent routine.
I thought I had sussed global variables, but I was wrong. Is there a simple way to pass variables on to subroutines so they can use them?
I believe it's in the definition of routines, in the parenthesese, but I don't understand the syntax. When I tried I got random errors on compiling in locations that made no sense, as if I'd removed a } somewhere.
I get "too many arguments" whatever I seem to do on the calling line. e.g. examplesubroutineCall(testvar); as soon as I add the testvar I get the too many arguments error.
Example
Void Test(
I have a string variable in a subroutine. Lets call it "x".
This subroutine calls another subroutine , on occasions, and that "called" subroutine needs to use the string "x" value from it's parent routine.
I thought I had sussed global variables, but I was wrong. Is there a simple way to pass variables on to subroutines so they can use them?
I believe it's in the definition of routines, in the parenthesese, but I don't understand the syntax. When I tried I got random errors on compiling in locations that made no sense, as if I'd removed a } somewhere.
I get "too many arguments" whatever I seem to do on the calling line. e.g. examplesubroutineCall(testvar); as soon as I add the testvar I get the too many arguments error.
Example
Void Test(