AAdd - Strange behavior
Publicado: Mié Jun 29, 2016 9:27 pm
Good Afternoon,
We would like to know if this behavior from AAdd is correct or a bug.
Consider the code:
The AAdd function changes the LOCAL variable from Button1Click method, even if it's not passed by reference.
Changing AADD(a01, 2) for a01 := {1, 2} solves the problem.
P.S: There is a simple test project with the code above attached.
- André Corrêa
We would like to know if this behavior from AAdd is correct or a bug.
Consider the code:
Código: Seleccionar todo
METHOD Button1Click( oSender ) CLASS TForm1
LOCAL a02 := {1}
F001(a02) //NOT PASSED BY REFERENCE
LogDebug(a02) //LOCAL VARIABLE SHOULD NOT BE CHANGED IN FUNCTION F001
MsgInfo("OK")
RETURN Nil
//------------------------------------------------------------------------------
FUNCTION F001(f1)
LOCAL a01 := {}
a01 := f1
AAdd(a01, 2) //SHOULD CHANGE ONLY LOCAL FUNCTION F001 VARIABLE a01,
//BUT CHANGES f1(Button1Click a02)
RETURN NIL
//------------------------------------------------------------------------------
Changing AADD(a01, 2) for a01 := {1, 2} solves the problem.
P.S: There is a simple test project with the code above attached.
- André Corrêa