Comparison of two files

This is a discussion on Comparison of two files within the REXX forums in Programming Languages category; Hi, I try to compare two files using regina rexx.But with no success. What must I do to compare two files? How can I put the result to one file? Thanks, Xi...

Go Back   Application Development Forum > Programming Languages > REXX

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-06-2008, 02:37 PM
Xizor
Guest
 
Default Comparison of two files

Hi,

I try to compare two files using regina rexx.But with no success. What
must I do to compare two files? How can I put the result to one file?

Thanks,
Xi
Reply With Quote
  #2  
Old 08-06-2008, 03:33 PM
Richard Brady
Guest
 
Default Re: Comparison of two files

Xizor wrote:
> Hi,
>
> I try to compare two files using regina rexx.But with no success. What
> must I do to compare two files? How can I put the result to one file?
>
> Thanks,
> Xi

Comparison algorithms are not trivial: how many lines to match for
synchronization and how to treat white space, immediately come to mind.

DOS once had a program called FC (formerly Filcomp) which had binary or
text flags to select the type of compare. Perhaps it still lurks
somewhere on your system.

Regards,
Richard
Reply With Quote
  #3  
Old 08-06-2008, 03:52 PM
Xizor
Guest
 
Default Re: Comparison of two files

> DOS once had a program called FC (formerly Filcomp) which had binary or
> text flags to select the type of compare. Perhaps it still lurks
> somewhere on your system.
>
> Regards,
> Richard


FC is there but I need the output to be written in one file and also
only the records that are different.
Reply With Quote
  #4  
Old 08-07-2008, 09:30 AM
Dave Saville
Guest
 
Default Re: Comparison of two files

On Wed, 6 Aug 2008 18:37:58 UTC, Xizor <mn@mn-ix.de> wrote:

> Hi,
>
> I try to compare two files using regina rexx.But with no success. What
> must I do to compare two files? How can I put the result to one file?


Go look for a port of the *nix program "diff" for whatever OS you use.
--
Regards
Dave Saville

NB Remove nospam. for good email address
Reply With Quote
  #5  
Old 08-07-2008, 12:38 PM
Xizor
Guest
 
Default Re: Comparison of two files

Can't use diff because I don't get it installed on that server. REXX
is the only thing I have except the DOS-Tools (from Windows 2003
Server). Fc or comp don't fulfill my needs because I need only the
file which is different from the others.
Reply With Quote
  #6  
Old 08-07-2008, 03:24 PM
ML
Guest
 
Default Re: Comparison of two files


> What must I do to compare two files?


Store file #1 in a "stem", AKA compound variable.
Read a line from file #2, and try to find it in the stem. If found,
clear the line in the stem so it isn't found twice or more and stpo
searching.

> How can I put the result to one file?


If found, don't write the line to file #3.

What have you tried so far?



---
Reply With Quote
  #7  
Old 08-07-2008, 05:54 PM
Xizor
Guest
 
Default Re: Comparison of two files

Here's what I did:

do while lines(dat1) <> 0
origdat1 = lines(dat1)
origdat2 = lines(dat2)
if origdat1 == origdat2 then
write to file1
else
write to file2
end

the write is call lineout of course.
Reply With Quote
  #8  
Old 08-07-2008, 05:57 PM
Xizor
Guest
 
Default Re: Comparison of two files

argh, mistyped...
> do while lines(dat1) <> 0
> origdat1 = linein(dat1)
> origdat2 = linein(dat2)



Reply With Quote
  #9  
Old 08-07-2008, 08:56 PM
ML
Guest
 
Default Re: Comparison of two files


> origdat1 = lines(dat1)
> origdat2 = lines(dat2)


/* Untested, with some obvious side-effects, without optimizations */
lines=0
DO WHILE Lines(dat1)>0
lines=lines+1
line.lines=Strip(LineIn(dat1))
IF line.lines='' THEN lines=lines-1
END
CALL LineOut dat1
line.0=lines
IF line.0=0 THEN EXIT
DO WHILE Lines(dat2)>0
line=Strip(LineIn(dat2))
IF line<>'' THEN DO
found=0
DO i=1 TO line.0
IF line==line.i THEN DO
found=found+1
line.i=''
END i
IF found=0 THEN DO
CALL LineOut notindat1,line
CALL LineOut notindat1
END
IF found>1 THEN SAY line 'occurs' count 'times in' dat1
END
END
CALL LineOut dat2



---
Reply With Quote
  #10  
Old 08-07-2008, 09:49 PM
ML
Guest
 
Default Re: Comparison of two files


> /* Untested


Still untested:

> ...
> IF line==line.i THEN DO
> found=found+1
> line.i=''


END

> END i
> ...




---
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:46 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.