[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Re: Much easier way to do file comparison



** Reply to message from Harry Binswanger  on Sun, 06 Nov 2005
22:19:13 -0500


≫ You can make the pertinent Redlining modes be
≫ any colors you want (e.g. red and green) with simple entries in the DFL
file.
≫ If you want, I'll implement that -- that would approach the efficiency of
≫ FINDDIFF.

> No, I'm sold on FINDDIFF.

I am too. But just for laughs, try this -- it's quite interesting (and maybe
even useful). NOBODY has seen a comparison like this before! It integrates
Additions and Deletions in a single file.

Instead of Doc#1 and Doc#2, it manages a BASE document (the document which will
show all the Additions + Deletions) and a COMPARISON document (the document
that you are comparing to, and the provider of the "Deletions"). Same thing,
different terminology. If you had two versions of a single document, the
newest one dated today would be the BASE doc, and the older version written six
months ago would be the COMPARISON doc.

CAll two such files into *adjacent windows*. They should NOT be massively
different in content! Then RUN this program from the CMline. Hit "Y"es (or
"N"o, to Abort) through the two initial queries. Voila!

This program is different because 1) it manages MoDed text within
Deletions/Additions (BOld, ITalic, UnderLine, etc -- ten MoDes altogether),
and 2) because it borrows the embedded MoDes of Redlining (without actually
*doing* any Redlining at all, or imposing Redlining's limitations, such
as the inability to switch into eXPanded mode), which means you have
standard XyWrite services for dealing intelligently with the result file.

And *that* means, when you're done examining the result, you can:
-- issue an ordinary XyWrite PE PutEdits command, to
  magically clear the *entire document* of Deletions, whilst
  retaining Edits/Additions -- in other words, get rid of
  the green and red (if those are your MDIN/MDDN colors), and
  thus restore the BASE document to its original condition
-- issue a XyWrite PEV PutEdits-Verify command, which has, along
  with the standard "Yes/No/Stop here/One more" options, the
  VERY INTERESTING, additional "U"ndo command, which will **restore** a
  Deletion to the BASE text. Remember: "Y"es on a Deletion means get
  rid of it (and kill the color), "Y"es on an Edit or Addition means
  retain it (and kill the color). "U"ndo on a Deletion means restore
  it (and kill color), "U"ndo on an Edit/Addition means !*delete*! it
  (and kill color)! "N"o skips & does nothing. Play with the options.

If you make a mistake, just RECA the document, to ABort and recall it.
(Do NOT use the XyWrite CE[V] command, because it will *Clear* both the
Deletions *and* the Additions, which is hardly what you want.)

You can adjust the MAtch (VAMA) sensitivity in Save/Get 01 at the top of the
program. I forgot that the minimum MAtch specificity is "2", not "1"...
Factory default is "40".

You can adjust the actual colors of the Deletion and Addition text in
SETTINGS.DFL. I use MD DN=71 (all my Redlining Delete MoDes are in the range
64-79) and MD IN=39 (all my Redlining Insert MoDes are in range 32-47). This
scheme yields green text for Additions, and red text for Deletions, which works
for me. If you change these numbers in your DFL file, quit XyWrite and
relaunch.

Simple, and pretty cool.

Here's the code, in compact form, followed by a "structured" and commented
listing. Store the code in a file -- I named mine UNIQOMP.PM
("RUN UNIQOMP.PM"). This should go in U2 eventually, if useful:

XPLeNCODE v2.0
b-gin [UNTITLED]
;*; UNIQOMP.PM Display [FD_]/[FM_]Deletions + Additions in a si
ngle file RJH 11/8/05[cr|lf];*;[cr|lf];*; USER VARIABLE (1):
[cr|lf];*; Enter eXPanded view, and adjust Save/Get 01 below{032}
(if necessary)[cr|lf];*; MAtch sensitivity in characters (ran
ge=2 or higher; factory default = 40)[cr|lf];*; To accept the
 default (currently={<}VA$MA{>}), leave Save/Get 01 empty![cr
|lf];*;[cr|lf]{<}SV01,{>};*; <== Enter MAtch sensitivity in S
/G 01, e.g. [255+065+069]SV01,10[255+065+070][cr|lf];*;[cr|lf
];*; -----DO NOT EDIT BELOW THIS LINE!-----[cr|lf];*;[cr|lf]{
<}IF{<}VA|01{>}<1{>}{<}LBA{>}{<}SX01,{<}VA$MA{>}{>}{<}SX01,{<
}IS01{>}{>}{<}EI{>}{<}IF{<}VA{021}01{>}<1{>}{<}GLA{>}{<}EI{>}
{<}IF{<}PV01{>}<2{>}{<}SV01,2{>}{<}EI{>}{<}SV02,BASE{>}{<}SU0
3,{<}SX04,"Is this the "+{<}IS02{>}+" file? (Y/n)"{>}{>}{<}SX
05,2{>}{<}SV06,Relining found in file - Abort{>}[BX_]es 1[Q2_
]{<}CUE,05{>}{<}GT03{>}{<}PR@04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}GT10{>}[BX_]
jmp {<}PV13{>}[Q2_]{<}SV10,{<}MDIN{>}{>}{<}GT10{>}{<}SV07,[99
8]{>}{<}SV09,IN{>}{<}SX10,{<}IS03{>}{>}{<}GT06{>}{<}EI{>}[AS_
][DF_]{<}IF{<}VA$DS{>}<{<}VA$DN{>}{>}[AS_]{<}SV10,{<}MDDN{>}{
>}{<}GT10{>}[CP_]{<}SV10,[999][999]{<}MDNM{>}{>}{<}GT10{>}[BX
_]seb [w<]MDDN[w>][Q2_][BX_]se [w<]MDDN[w>][Q2_]{<}SV07,[99
9]{>}{<}SV09,DN{>}{<}SX10,{<}IS04{>}{>}{<}GT06{>}[AS_]{<}EI{>
}[XD_][AS_]{<}GLG{>}{<}EI{>}[BX_]d MA={<}PV02{>}[Q2_][AS_]{<}
SV06,Done - Command PEV to adjust file{>}{<}GLB{>}
-nd
XPLeNCODE

======================================

Structured listing (NOT part of the real code above!):

;*; USER VARIABLE (1):
;*; Enter eXPanded view, and adjust Save/Get 01 below (if
                necessary)
;*; MAtch sensitivity in characters (range=2 or higher;
                factory default = 40)
;*; To accept the default (currently=), leave Save/Get
                01 empty!
;*;
;*; <== Enter MAtch sensitivity in S/G 01
;*; -----DO NOT EDIT BELOW THIS LINE!-----
;*;
  <1>
    
  <1>
    
  
  <2>
    
  
+" file? (Y/n)"≫
;*; Setup the PRompt string just once (issue it
                twice)
;*; Potential PRompt
BX es 1Q2;*; Kill "Not Found" error beeps
;*; CountUp loop, executed 2 times per value in
                , between  and
                
){contains}"N">
    ;*; If Aborting...
    {contains}"C">;*; If "C"OMPARISON window
                displayed...
      TF WG AS TF WG
    ;*; ...restore status ante
  ;*; Issue Abort PRompt, else Done PRompt
  ;*; Quit
XH YD XD XP TF SI DO FF ;*; Initialize each file to compare:
                kill menus, kill any existing
                DeFined state, switch to
                eXPanded view, go TopFile,
                SetInsert cursor state,
                Force_reFreshed screen
BX se Q2;*; Loop to check for preexisting
                Redlining...
  )>
    ;*; If Redlining found, Abort
  

AS ;*; Toggle to AdjacentScreen, PRompt for
                the "comparison" file
;*; End of CountUp loop
Q2 ;*; Set FD/FM "MAtch"
                sensitivity
;*;
;*;
;*; Source strings to replace MoDes within additions
                and deletions
BX se {OR}≪MD Q2
  <>"[">
    DF BX se/f ≫Q2 DF DN
    ==0!=="NM">
      
    
    ==0>
      
    
    
    
  
RC BD BX se ≫Q2 >;*; SUbroutine that parses and puts
                replacement MoDe strings for
                additions and deletions
;*; Beginning of main FD/FM compare loop
  <1>;*; Have we reached FileEnd yet? No=0|Yes=1
    FD {less than}BX jmp Q2
      
      
    
  ;*; Are there MoDes in Doc #1 additions? If Yes, convert
                to Insert MoDes
  AS DF
    ≪VA$DN≫;*; Toggle to Doc #2, stop
                DeFining text, see if the DF
                block has any length (i.e. do
                deletions exist?)...
      AS CP
      
      BX seb ≪MDDN≫Q2 BX se ≪MDDN≫Q2 
      ;*; If MoDes in Doc #2, convert to Delete
                MoDes
      AS
    
    XD AS
    
  
;*; End of main FD/FM compare loop
BX d MA=Q2 ;*; Restore original "MAtch" sensitivity
AS  to adjust file>
;*; Share identical code at  (Quit!)

-----------------------------
Robert Holmgren
holmgren@xxxxxxxx
-----------------------------