traherne@murdu.oz (Richard Jordan) (10/25/90)
Here is a macro I wrote for use with Ultramacros 3.1. It adds what is virtually a "diff" command to Appleworks. It will compare any two files on the desktop and print out, in a third file, the pairs of lines that differ, together with their line numbers. Compile the macro, open a new file, and press ba-/ (or whatever you label it for your set of macros). It will ask you to select the two files to compare from the desktop menu, give you the option of quiting if the files are not the same length (it will work even if they aren't), and then get on with it. I use it in the word processor to collate two versions of the same text. It will also work in the database, but can only compare one pair of catagories at a time there. The macro uses sa-2 from the default set that comes with Ultramacros. If you don't use that macro, substitute oa-q:print Q:rtn for sa-2 where it occurs. I tried to use the new & "(y/n)" token instead of $3=getstr 1, but it messed up the rest of the macro. I would welcome any advice (by e-mail) on how to do it right. start <ba-/>:<all><clear : Q = peek 3156 : oa-q msg 'Select first file (A) for comparison.' : input : rtn : oa-9 : posn C,D : oa-1 : zoom : A = peek 3156 : sa-2 : oa-q msg 'Select second file (B) for comparison.' : input : rtn : oa-9 : posn E,F : if D < F or D > F msg 'FILES ARE DIFFERENT LENGTHS. Continue? (y/n)': $3 = getstr 1 : endif : if $3 = "n" or $3 = "N" then sa-2 : stop : endif : if D < F then D = F : endif : oa-1 : zoom : B = peek 3156 : sa-2 : begin : display 0 : oa-q : print A : rtn : $1 = cell : posn X,Y : if Y = D or S = D then display 1 : stop : endif : down : oa-q : print B : rtn : $2 = cell : posn R,S : down : if $1 = $2 then rpt : else sa-2 : display 1 : print Y : print "A: " + $1 : rtn : print S : print "B: " + $2: rtn : rpt>!