Hello all,
I need to make an intelligent diff between 2 arrays.
this arrays contain lines from files and I need to compare them line by line.
I have built a diff that goes line by line and if the line is matches -ok ,but if the line is misplaced then it come out with the line number that there is a match.
The problem is that one array may have a bunch of lines that doesn't exsist on the other array - in this case I have many lines that are misplaced (from that point and on) and what I need to do is to display these lines as missing but when they sync up again the display should be equal.
Example
array 1: sunday,monday,tuesday,friday,saturday
array 2:sunday,monday,tuesday,wednesday,thursday,friday,saturday
now my display is this (in 2 frames side by side)
sunday sunday
monday monday
tuesday tuesday
friday wednesday (missing)
saturday thursday (missing)
friday (misplaced)
saturday(misplaced)
of course the arrays can be much longer and identical from thsi point on but my diff shows that there are many differences when actually there are only 2.
and what I need to display is:
sunday sunday
monday monday
tuesday tuesday
wednesday (missing)
thursday (missing)
friday friday
saturday saturday
I hope all is understood....
Thanks
urgent help needed - diff between arrays
Moderator: General Moderators
hey yaron
well from what ive understood i think that when thrz a mismatch or missing u increment the index of both arrays that is if suppose:
array1 = sunday,monday,tuesday,friday,saturday;
array2 = sunday,monday,tuesday,wednesday,thursday,friday,saturday;
when u comparing these both u doing it like
array2 == array1 then
u print the actual values
and increment i by one
and if both dont match u still increment the i by one so like array1 contains only 4 values so when two mismatches are found the i is still incremented and array1 reaches a state whr it doesnt have anymore values to compare ... so when thrz a mismatch don increment the index variable of array1....
well im not sure if this is wat u were lookin for but well jus tryen to help
hope it helps ya
bye
well from what ive understood i think that when thrz a mismatch or missing u increment the index of both arrays that is if suppose:
array1 = sunday,monday,tuesday,friday,saturday;
array2 = sunday,monday,tuesday,wednesday,thursday,friday,saturday;
when u comparing these both u doing it like
array2 == array1 then
u print the actual values
and increment i by one
and if both dont match u still increment the i by one so like array1 contains only 4 values so when two mismatches are found the i is still incremented and array1 reaches a state whr it doesnt have anymore values to compare ... so when thrz a mismatch don increment the index variable of array1....
well im not sure if this is wat u were lookin for but well jus tryen to help
hope it helps ya
bye
I thought about that and...
I wish things would have been that easy.
The arrays may or may not sync again so when I see that they do not match I have to know if its because something is added to one of them or its a regular difference.
I can't just type nothing and assume it will sync up again...
The arrays may or may not sync again so when I see that they do not match I have to know if its because something is added to one of them or its a regular difference.
I can't just type nothing and assume it will sync up again...