On Wed, 27 May 2009, Rossine wrote:
Hi,
> How to do that which in the example below, the element 1 of "aVar[1]" is not
> changed?
> [CODE]
> FUNCTION MAIN
> local aVar1 := { 1, 2, 3 }
> local aVar2
> aVar2 := avar1
After simple assignment by := both variables points to the same array body.
> aVar2[1] := 5
> ? aVar1[1] && Here return 5 . Why ?
because both vars uses the same array after above assignment.
If you do not like it and you want to make full array clone before
assigning array reference to variable then you should make it in the
same way as in Clipper and instead of:
aVar2 := aVar1
you should use:
aVar2 := AClone( aVar1 )
best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour