[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

compare 2 flat files.



Ravi-

The first thing I noticed was that your program will never enter the second
while loop because 2 will never
equal 1. The second is that after the first time you find a line that doesn't
match, it's possible that all subsequent lines will not match.
        File 1                  File 2
        hello                   hello
        I                               world
        am                              I
        fine                            am
                                        fine

You are comparing not only the content of the lines, but their position. This
may be what you want, but if not, my suggestion would be to read file 2 into an
array and then do your string compare.

-Danielle Logan

*******************************************************************************************
hi everybody,
    i am opening file 1 and 2 for reading and file 3 for writing.  i
wanted to compare first two files, record wise (line wise) and write the
records which are not in file 2 in file 3.
    the code i am using is as follows :

while 1 = 1
   read 1 into $rec1:50

   while 2 = 1
      read 2 into $rec2:50
      if $rec1 = $rec2
         break
      else
         write 3 from $rec1
      end-if
      if #end-file = 1
         break
      end-if
   end-while

   if #end-file = 1
      break
   end-if

end-while

please let me if i can do what i wanted to do by modifying the code
above.
thanx in advance.

ravi c gaddam.

ATTRIBS.BND