In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
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
//------------------------------------------------------------------------------
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.
The arrays are always passed by reference (though not place @ the pass as a parameter)
If you need to pass the "value" but not "reference" use aclone() function that generates a copy of the array
regards