However, you should expect that the local variable A should preserve its value before the call to Sub2, and be correctly incremented afterwards. What you see is not what I would expect. Certainly you can use a global, but as long as you use the local value of A in Sub1, it should be preserved there.
To be on the safe side though, you should initialise the value afer declaring it:
[code]
Sub Sub1
Local A as byte
A = 0 'initialise the value
Incr A ' A=1
Call Sub2
Incr A ' A should be 2 after this
Print A
End Sub
[code]
A local variable is simply a value inserted on the stack, so it may not necessarily be initialised to zero.
↧