resultsArray = RTI_Diff( var1, var2 )
Now before we go any further I'd like you to take a deep breath, centre your chakra and repeat the following mantra...
From exclusive, to inclusive. From exclusive, to inclusive. From exclusive, to inclusive. From exclusive, to inclusive.
OK are you still with me? Good. Keep that mantra in mind because you're going to need it to make sense of what comes hereinafter...
Strictly speaking to make it more comprehensible to OI programmers RTI could have called it RTI_SIMILARITIES_AND_DIFFERENCES but that'd suck to type every time.
The easiest way to describe the use of the function is to show it in operation. So consider two data rows having similar but different makeups :-
To highlight the differences - line 7 is MVed in VAR2, lines 10 and 11 are missing, line 17 is different, and there are two inserted lines between line 18 and 19.
Now consider the result of calling RTI_DIFF with these two variables. The resultant return is a field mark delimited array having a line for each significant fact/similarity. Each line has five multivalues as follows :-
<0, 1> = nature of comparison
<0, 2> = starting line number var 1
<0, 3> = ending line number var 1
<0, 4> = starting line number var 2
<0, 5> = ending line number var 2
<0, 2> = starting line number var 1
<0, 3> = ending line number var 1
<0, 4> = starting line number var 2
<0, 5> = ending line number var 2
The nature of the comparison can have the values "equal", "replace", "insert" or delete".
So to illustrate with the results of our call to RTI_DIFF using the two variables above the result is
Now remember our mantra? From exclusive, to inclusive? Well let's apply it here. Remember that what we're actually asking is "What do we need to do to Var1 to make it the same as Var2?". What this result tells us is that :-
- Lines 1 to 6 are the same in both and can be ignored
- Line 7 is different and should be replaced in string A with line 7 fronm string B
- Lines 8 and 9 are the same and can be ignored
- Lines 10 and 11 from string A should be deleted
- Lines 12 to 16 are the same as lines 10 to 14 (of course as we've deleted 2 lines 12 to 16 has become 10 to 14 but...)
- Line 17 in string A should be replaced with line 15 from string B
- Lines 18 and 16 are the same and can be ignored
- At line 18 in string A insert lines 17 and 18 from string B
- Lines 19 and 20 are the same and can be ignored.
Thanks Sprezz, your posts are like a ray of sunshine on a cloudy day.
ReplyDeleteawww bless :). Thank you.
ReplyDelete