On 29Sep, 2009, at 10:15 AM, Rossine wrote:
Hello
This sample:
[CODE]
function main
local aArr1 := { }
local aArr2 := { }
? aArr1 != aArr2
return NIL
[ENDCODE]
generate this error:
[ERROR]
Error BASE/1072 Argument error: <>
Called from MAIN(6)
[ENDERROR]
I see that this is correct, it also occurs in the clipper same
error. How do
I compare two arrays ?
Hello Rossine, here is a little function that I wrote years ago to
compare two array contents:
<prg>
FUNCTION aCompare(a1,a2)
LOCAL r:=.T.,v
IF !valtype(a1)=="A" .OR. !valtype(a1)==valtype(a2) .OR. !
len(a1)==len(a2)
RETURN .F.
ENDIF
aeval(a1,{|e,i|
iif
(r
,r:=iif((v:=valtype(e))=="A",aCompare(e,a2[i]),v==valtype(a2[i]) .AND.
e == a2[i]),NIL) })
RETURN r
</prg>
Then you simply use:
IF aCompare( a1, a2 ) // TRUE on equal array contents
....
best regards,
Teo
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour