My co-worker created a local variable and passed it to a procedure. The procedure took the private parameter and changed it.
I thought that the parameter should go out of scope when the procedure ends. However, the variable's value is changed in the calling program.
UDFPARMS is set to the 'VALUE'.
LOCAL X
X = 1
Y = 1
DO foo WITH X
? X,Y
RETURN
PROCEDURE foo
PARAMETER X
PRIVATE Y
X=2
Y=2
RETURN
OUTPUT: 2,1
In this code, Y behaves normally. It value is set to 2 in foo, and reverts to 1 in the main program. X however, is changed to 2 even though its local in main.
Is this expected bevavior?
The workaround is easy... dont use the same name, and prefix params with tn.
But the mystery remains.
Hans