Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I compare 2 files of record?

Posted on 2003-02-23
6
Medium Priority
?
158 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
5 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

579 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