Code: Select all

`logmode l`

subroutine a(scalar !sum)

!sum = 0

for !k= 1 to 10 '!k is used for a different purpose in a than in b

!sum = !sum + !k

next

endsub

subroutine b

!k= 1

!sum = 0

call a(!sum)

logmsg k={!k} sum={!sum} 'Will display 10 instead of 1 for !k

endsub

call b

Specifically what I would like to see is a syntax like the following to be able to declare some program vars as being local to their subroutine:

Code: Select all

`logmode l`

subroutine a(scalar !sum)

local !k ' <===== LOCAL PROGRAM VAR DECLARATION HERE THAT WON'T REFERENCE THE GLOBAL VARIABLE DEFINED IN b

!sum = 0

for !k = 1 to 10

!sum = !sum + !k

next

endsub

subroutine b

!k= 1

!sum = 0

call a(!sum)

logmsg k={!k} sum={!sum} 'Will display 10 instead of 1 for !k

endsub

call b

Would something like this be possible? I would imagine that it's non-trivial because it requires keep a local variable stack for each subroutine invocation.