home *** CD-ROM | disk | FTP | other *** search
- program COMP;
-
- {written by Case in January 07, 1993}
-
- {this utility compares two files}
-
-
- uses dos;
-
- var file1,file2:string;
- i,n:longint;
- cha,chb:char;
- a,b:file of byte;
- equal,siz:boolean;
- f1,f2:text;
- par:word;
-
-
-
-
-
-
- procedure esa(num:longint);
-
- var aux,k,m,elev,nn,conv:longint;
-
-
- procedure writ(nn:integer);
-
- begin
-
- case nn of
- 10: write ('A');
- 11: write ('B');
- 12: write ('C');
- 13: write ('D');
- 14: write ('E');
- 15: write ('F');
- else write (nn)
- end {end of case}
-
- end; {procedure writ}
-
-
-
- begin {procedure esa}
-
-
- write (' ($');
-
- if (num<10) then write(num)
-
- else begin
-
- k:=0;
- aux:=num;
-
- while aux>15 do begin
- aux:=trunc(aux/16);
- inc(k,1) end;
-
- elev:=conv;
-
- while k>0 do
- begin
- elev:=16;
-
- for m:=1 to k-1 do elev:=elev*16;
- nn:=trunc(num/elev);
-
- writ(nn);
-
- num:=num - (nn*elev);
- dec(k,1)
-
- end;
-
- writ(num)
-
- end;
-
- writeln(')')
-
- end; {procedure esa}
-
-
-
-
-
-
- begin {main}
-
- i:=0;
- equal:=true;
-
- par:=paramcount;
-
- case par of {I'm reading files'names}
- 0:begin writeln('Input file1''name');
- readln(file1);
- writeln('Input file2''name ');
- readln(file2) end;
- 1:begin file1:=paramstr(1);
- writeln ('File 1 is ', file1);
- writeln ('Input File2''name ');
- readln(file2) end;
- else begin file1:=paramstr(1);
- writeln ('file 1 is ', file1);
- file2:=paramstr(2);
- writeln ('file 2 is ', file2) end
- end; {end of case}
-
-
- assign(a,file1); {I'm reading files'lenght}
- assign(b,file2);
- reset(a);
- reset(b);
- if filesize(a)=0 then begin writeln('File ',file1,' not found');
- read(cha); halt end;
- if filesize(b)=0 then begin writeln('File ',file2,' not found');
- read(cha); halt end;
-
- siz:= (filesize(a))<>(filesize(b));
- if siz then writeln('file have different size')
- else i:=(filesize(a));
- close(a);
- close(b);
-
-
- if i<>0 then begin {I'm comparing files}
- assign(f1,file1);
- assign(f2,file2);
- reset(f1);
- reset(f2);
- for n:=0 to i do
- begin
- read(f1,cha);
- read(f2,chb);
- if cha<>chb then begin
- write(cha,' <> ',chb,' character N.',n);
- esa(n);
- equal:=false end
- end;
- close (f1);
- close(f2)
- end;
-
-
-
-
- {final result}
-
- if (equal and not siz) then writeln('file compare ok');
- writeln('end of compare');
- read(cha)
-
- end.
-
-
-
-