?
Solved

How do I compare 2 files of record?

Posted on 2003-02-23
6
Medium Priority
?
157 Views
Last Modified: 2010-04-04
hello,
I need to compare two files which contain records. how can I do it?

ty
0
Comment
Question by:Ernestele
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Accepted Solution

by:
billious earned 100 total points
ID: 8003194
var
  same    : Boolean;
  index   : byte;
  r1      : recordtype;
  r1b     : array [1..sizeof(recordtype)] of byte
              absolute r1;
  r2      : recordtype;
  r2b     : array [1..sizeof(recordtype)] of byte
              absolute r2;


Then read your files

  repeat
   same := true;
   read(f1,r1);
   read(f2,r2);
   for index := 1 to sizeof(recordtype) do
     same := same and (r1b[index] = r2b[index]);
   if not same writeln('records differ');
  until eof(f1) and eof(f2);

I'd guess that the root of your question is that "r1 = r2" won't compile.

Naturally, the above code makes a number of assumptions, like that files are of the same length, and does not cater for inserted/deleted records or records switched in order.

But I think this should help if my hunch is right.

...Bill
0
 
LVL 46

Expert Comment

by:aikimark
ID: 8003365
look at DLSuperC.com offerings.  This shareware program is probably the best file comparison utility available.  You can launch it in batch mode.
0
 
LVL 3

Expert Comment

by:ILE
ID: 8005622
this will be be work for any two caind of files with any sizes



var
fil: file of byte;
fil1: file of byte;
 b,b1:byte;
 i:longint;
 same:boolean;
begin
same:=true;
assign(fil,'c:\firstfile');
reset(fil);
assign(fil1,'c:\secondfile');
reset(fil1);
if length(fil)=lentth(fil1) then
begin
 for i:=0 to filesize(fil)-1 do
  begin
    seek(fil,1); seek(fil1,1);
    read(fil,b) read(fil1,b);
    if b<>b1 then same=false;
  end;

end else same=false;
close(fil);
close(fil1);
end;


result is in the same


if the question is for data bases
answer is  this is a trick work only with indexed bases
u have a table1 and a table2 with two bases

put 2 batchmove
put table3

first data base
batchmove1.source=table1;
batchmove1.destination=table3;
batchmove1.mode:=batcopy;
batchmove1.execute;

batchmove2.source=table2;
batchmove2.destination=table3;
batchmove2.mode:=batdelete
batchmove2.execute


if table3 is empty then table1 and table2 are the same

work with any indexed bases

if there is no index u mey create index and do the same :))

this is better then go record by record to compare


if something is not clear just ask

 

0
 

Expert Comment

by:CleanupPing
ID: 9317114
Ernestele:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:kacor
ID: 9956106
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to split points between billious and ILE
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question