Passing a variable to a subroutine within a subroutine question.
I tried to pass a variable to a subroutine which is inside of another subroutine and it is not sucessfull. For example:
Something like this format does not work unless even if I declare in the begining of the program: cs = 5
However, If I change it to this, it works:
·Any ideas?
temp1 VAR Byte cs VAR Byte Subroutine1 SUB 2 Subroutine2 SUB 1 PROGRAM Start Main: cs = 5 Subroutine1 3, cs END SUB Subroutine1 temp1 = __PARAM1 cs = __PARAM2 [b]Subroutine2 cs[/b] temp1 = temp1 + 1 'Do something with temp1 now.... ENDSUB SUB Subroutine2 cs = __PARAM1 cs = cs + 1 'Do something with cs now.... ENDSUB
Something like this format does not work unless even if I declare in the begining of the program: cs = 5
However, If I change it to this, it works:
temp1 VAR Byte cs VAR Byte Subroutine1 SUB 1 Subroutine2 SUB 1 PROGRAM Start Main: Subroutine1 3 END SUB Subroutine1 temp1 = __PARAM1 [b]Subroutine2 5[/b] temp1 = temp1 + 1 'Do something with temp1 now.... ENDSUB SUB Subroutine2 cs = __PARAM1 cs = cs + 1 'Do something with cs now.... ENDSUB
·Any ideas?
Comments
regards peter
Those were example ideas based on code I am trying to write. However, my main question was if it was possible to have variables passed into another subroutine and you have answered that. I will relook at my code tonight and make sure I have the latest SX 2.0.x. Thanks again for the confirmation.