Hi,
Am wanting to detect whether an array has changed from a clone of the
original array.
The arrays are multidimensional.
The == operator tests whether two array references point to the same array.
I want to detect any change in structure or contents between two separate
arrays.
Have looked through the docs but cant find anything, I was hoping not to
have to write something!
Any thoughts would be appreciated.
Chris Gillard
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.
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.
Function to Compare two arrays ....
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
- ignacio
- Site Admin
- Mensajes: 9447
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Function to Compare two arrays ....
Chris Gillard escribió el mar, 28 junio 2011 10:03Hi,
Am wanting to detect whether an array has changed from a clone of the
original array.
The arrays are multidimensional.
The == operator tests whether two array references point to the same array.
I want to detect any change in structure or contents between two separate
arrays.
Have looked through the docs but cant find anything, I was hoping not to
have to write something!
Any thoughts would be appreciated.
Chris Gillard
Hi,
I believe there is no function for that purpose on Clipper or Harbour. Sorry.
regards,
Am wanting to detect whether an array has changed from a clone of the
original array.
The arrays are multidimensional.
The == operator tests whether two array references point to the same array.
I want to detect any change in structure or contents between two separate
arrays.
Have looked through the docs but cant find anything, I was hoping not to
have to write something!
Any thoughts would be appreciated.
Chris Gillard
Hi,
I believe there is no function for that purpose on Clipper or Harbour. Sorry.
regards,
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
- Carlos Ortiz
- Mensajes: 873
- Registrado: Mié Jul 01, 2009 5:44 pm
- Ubicación: Argentina - Córdoba
- Contactar:
Function to Compare two arrays ....
Chris te adjunto una funcion, creo que te puede servir.
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,22},11 }
ArrayCompare(a1,a2)
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,22},12 }
ArrayCompare(a1,a2)
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,23},11 }
ArrayCompare(a1,a2)
Saludo. Carlos Ortiz.
Argentina
************************
Function ArrayCompare(a1,a2)
************************
local lEqual,x,y
lEqual := Len(a1) == Len(a2)
if lEqual
for x = 1 to Len(a1)
if ValType(a1[x])=="A"
for y = 1 to Len(a1[x])
lEqual := a1[x,y] == a2[x,y]
if lEqual == .F. ; exit ; endif
? "a1:",a1[x,y], "a2:",a2[x,y] // test output
next y
else
lEqual := a1[x] == a2[x]
if lEqual == .F. ; exit ; endif
? "a1:",a1[x], "a2:",a2[x] // test output
endif
if lEqual == .F. ; exit ; endif
next x
endif
? lEqual // test status
return lEqual
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,22},11 }
ArrayCompare(a1,a2)
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,22},12 }
ArrayCompare(a1,a2)
a1 = { {111,222,333},{11,22},11 }
a2 = { {111,222,333},{11,23},11 }
ArrayCompare(a1,a2)
Saludo. Carlos Ortiz.
Argentina
************************
Function ArrayCompare(a1,a2)
************************
local lEqual,x,y
lEqual := Len(a1) == Len(a2)
if lEqual
for x = 1 to Len(a1)
if ValType(a1[x])=="A"
for y = 1 to Len(a1[x])
lEqual := a1[x,y] == a2[x,y]
if lEqual == .F. ; exit ; endif
? "a1:",a1[x,y], "a2:",a2[x,y] // test output
next y
else
lEqual := a1[x] == a2[x]
if lEqual == .F. ; exit ; endif
? "a1:",a1[x], "a2:",a2[x] // test output
endif
if lEqual == .F. ; exit ; endif
next x
endif
? lEqual // test status
return lEqual
@dbfarma
www.dbfarma.com.ar
www.dbfarma.com.ar
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Function to Compare two arrays ....
Thanks for the input both and to Carlos for some code that I have used and
works well.
Thank you.
Chris
"Carlos Ortiz" <cortizassist@hotmail.com> wrote in message
news:[email=4e0b8c60@svctag-j7w3v3j....]4e0b8c60@svctag-j7w3v3j....[/email]
> Chris te adjunto una funcion, creo que te puede servir.
>
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,22},11 }
> ArrayCompare(a1,a2)
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,22},12 }
> ArrayCompare(a1,a2)
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,23},11 }
> ArrayCompare(a1,a2)
>
> Saludo. Carlos Ortiz.
> Argentina
>
> ************************
> Function ArrayCompare(a1,a2)
> ************************
> local lEqual,x,y
> lEqual := Len(a1) == Len(a2)
>
> if lEqual
> for x = 1 to Len(a1)
> if ValType(a1[x])=="A"
> for y = 1 to Len(a1[x])
> lEqual := a1[x,y] == a2[x,y]
> if lEqual == .F. ; exit ; endif
> ? "a1:",a1[x,y], "a2:",a2[x,y] // test output
> next y
> else
> lEqual := a1[x] == a2[x]
> if lEqual == .F. ; exit ; endif
> ? "a1:",a1[x], "a2:",a2[x] // test output
> endif
> if lEqual == .F. ; exit ; endif
> next x
> endif
> ? lEqual // test status
>
> return lEqual
>
>
works well.
Thank you.
Chris
"Carlos Ortiz" <cortizassist@hotmail.com> wrote in message
news:[email=4e0b8c60@svctag-j7w3v3j....]4e0b8c60@svctag-j7w3v3j....[/email]
> Chris te adjunto una funcion, creo que te puede servir.
>
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,22},11 }
> ArrayCompare(a1,a2)
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,22},12 }
> ArrayCompare(a1,a2)
> a1 = { {111,222,333},{11,22},11 }
> a2 = { {111,222,333},{11,23},11 }
> ArrayCompare(a1,a2)
>
> Saludo. Carlos Ortiz.
> Argentina
>
> ************************
> Function ArrayCompare(a1,a2)
> ************************
> local lEqual,x,y
> lEqual := Len(a1) == Len(a2)
>
> if lEqual
> for x = 1 to Len(a1)
> if ValType(a1[x])=="A"
> for y = 1 to Len(a1[x])
> lEqual := a1[x,y] == a2[x,y]
> if lEqual == .F. ; exit ; endif
> ? "a1:",a1[x,y], "a2:",a2[x,y] // test output
> next y
> else
> lEqual := a1[x] == a2[x]
> if lEqual == .F. ; exit ; endif
> ? "a1:",a1[x], "a2:",a2[x] // test output
> endif
> if lEqual == .F. ; exit ; endif
> next x
> endif
> ? lEqual // test status
>
> return lEqual
>
>