Quote: "In fact it forgets where it came from as well as all data that was there. "
This is only partly correct. GOTO is control change, we use it to transfer program execution to another fixed point in our program, when we don't wish to return to the calling location.
The operation doesn't alter variables contents at all, although I seem to recall that DBpro still allows jumping between scopes, so jumping into a function from a global scope or from inside a function to some other point. Both could be potentially hazardous to your programs health.
rem Global Scope
A = 112233
MyFunction(100)
sync
wait key
end
Function MyFunction(InputParam)
print "Local Variables in MyFunction"
print InputParam
REM jump scopes into a completely different function..
rem This has undefined bevaiour written all over it !
goto LocalScopeLabel
EndFunction
FUnction MyFunction2()
LocalScopeLabel:
print "Local Variables in MyFunction 2"
print SomeLocalVariable1
print SomeLocalVariable2
gosub PrintA
EndFunction
PrintA:
print "Global Variables "
print A
return
Edit: Yep it still allows jumping between them, you'll notice when we jump between two different functions, the locals in the second function are effectively still the previous functions frame. So if you wrote to those variables you'd be writing to the previous function locals.. Which could some very undesirable results indeed.