SmallBASIC icon indicating copy to clipboard operation
SmallBASIC copied to clipboard

Local variable scope extends to called function

Open chrisws opened this issue 3 years ago • 0 comments

sub huh
  'local k  - workaround to avoid polluting foo's k
  print k 'invalid: prints 123
  k = 999
end

sub foo
  local k
  k = 123
  huh()
  print k ' invalid: prints 999
end

foo()
print k ' should be 999 since huh() changed global k
pause

chrisws avatar May 14 '22 05:05 chrisws