Tereza, I don't think you can compare arrays like that... I never tried to do so, I always sort the keys and iterate thru them.
andre On Mon, Sep 19, 2011 at 5:30 PM, Tereza Snyder <ter...@califex.com> wrote: > I recently encountered a problem implementing an undo function in a script. > I needed to compare two arrays to see if any values had changed, like this: > > put (tArray1 <> tArray2) into sDirtyFlag > > so that sDirtyFlag would be true when the arrays failed to match. However, > sDirtyFlag was always false! No matter what! > > I put the two arrays into globals and compared them in the message box, > like this: > > put (gArray1 = gArray2), and the result was always correct. I thought there > was some hidden horrible error in my script that dementia prevented me from > seeing, until I realized that in my script I was using "<>" not "=" to > compare. > > See if the following script, pasted into a button, mystifies you the way it > did me. If you comment out the line: > > put "xx" into tTestA2["low2"] > > so that the arrays ARE equal you might see, as I did, that the comparison > is correct. > > Evidently in LiveCode 4.5.3, buildnumber 1444, on MacOS 10.6.8, > > "(tTestA1 <> tTestA2)" is not the same as "not(tTestA1 = tTestA2)" when the > arrays are unequal. > > (I apologize that the example is so elaborate, I was attempting to > reproduce the error environment.) > > > tereza > > -- mind the linewraps > ------------------------------ > > on mouseUp > DoArrayComparison > end mouseUp > > on DoArrayComparison > -- create 1 array > repeat for each item iii in "low1,low2,low3" > repeat for each item ii in "lower1,lower2,lower3" > repeat for each item i in "lowest1,lowest2,lowest3" > put "data" && iii && ii && i into tA1[iii][ii][i] > end repeat > end repeat > end repeat > -- create 2 arrays from it > put tA1 into tTestA1 > put tTestA1 into tTestA2 > -- make them unequal > put "xx" into tTestA2["low2"] > -- do three comparisons > put "(tTestA1 = tTestA2)="& (tTestA1 = tTestA2) &cr& \ > "(tTestA1 <> tTestA2)="& (tTestA1 <> tTestA2) &cr& \ > "not(tTestA1 = tTestA2)="& not(tTestA1 = tTestA2) > end DoArrayComparison > > ------------------------------- > > -- > Tereza Snyder > Califex Software, Inc. > <www.califexsoftware.com> > > > > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- http://www.andregarzia.com All We Do Is Code. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode