Below is a simplified version of the code just showing the effect. When the code is ran it executes a test() procedure and adds debug information to a global output string both inside and outside the test() procedure. It displays the string after all is done.
Code: Select all
EnableExplicit
Global mystery$
Define testCounter, maxCounter = 5, a$
Procedure.i test()
Static t
t + 200
mystery$ + " Time: " + t
Debug mystery$
ProcedureReturn t
EndProcedure
While testCounter <= maxCounter
;Do not make an assignment like the following; the 'old' value of mystery$ is used before test() is executed.
mystery$ + "; " + testCounter + ": " + test()
;Instead separate the before and after into two separate variables before
;recombining them so that the changes in test() can be accounted for properly.
;a$ = "; " + testCounter + ": " + test(): mystery$ + a$
testCounter + 1
Wend
MessageRequester("Results", mystery$)
If you run the debugger the contents of mystery$ are shown as it is inside the test() procedure and again the contents are shown in a MessageRequester() after all is done. They do not agree and that highlights the bad assignment issue. It isn't a bug but it is bad programming. I may be the only one who would ever hack something together like this but I thought I would post it here as an example of what not to do.

@Edit: Modified comment line containing function code to contain actual functioning code.
