Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Text file difference code

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#TextDiff or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/TextDiff


This is a quick bit of code that checks that all lines in one text file are in another text file.





Note the lines don't have to be in the same order but need to be in the file.

This is a handy bit of code for checking text files are not different.

It also remembers the files you last compared, and also displays the line it cannot find in a copyable input box.

It gives up if it finds more than 5 lines missing.

 

Stick this code in a button:

Dim uiw As New notesuiworkspace

Dim uidoc As notesuidocument

Set uidoc = uiw.currentdocument

Dim doc As notesdocument
Set doc = uidoc.document

Dim s As New notessession
f1 = s.getenvironmentstring("ef1")
f2 = s.getenvironmentstring("ef2")


f1= Inputbox$("File1?", "File", f1)
f2=Inputbox$("File2?","File", f2)

Call s.setenvironmentvar("ef1", f1)
Call s.setenvironmentvar("ef2", f2)

fileNum% = Freefile

counter% = 0



Open f1 For Input Access Read As fileNum%


Print "files" fileNum% & " " & fileNum2%
count1=1

errcount=0
Do Until count1 > 10000 Or Eof(filenum%) or errcount>5

Line Input #filenum%, first

fileNum2% = Freefile

Open f2 For Input Access Read As fileNum2%
found=False
count2=1
Do Until found=True Or Eof (fileNum2%)
Line Input #fileNum2%, sec

If Cstr(first) = Cstr(sec) Then

If count1=count2 Then
Print ("Line " & count1 & " found at " & count2 )
Else
Print ("Line " & count1 & " found at " & count2 & " different number!")
End If
found=True

End If

count2=count2+1
Loop

If Eof(FileNum2%) Then
r= Inputbox$ ("Cannot find line " & count1, "", first )

errcount=errcount+1

End If
Close #fileNum2%
count1=count1+1
Loop

If errcount>5 Then

msgbox "Found too many errors!"

End

End If


If Eof(FileNum%) Then
Msgbox "Finished! Wahooo! " & count1
Close #fileNum%
End
End If

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Web Services Platform Architecture: Soap, WSDL, WS-Policy, WS-Addressing, WS-Bpel, WS-Reliable Messaging and More by Francisco Curbera, Frank Leymann, Tony Storey, Donald Ferguson, Sanjiva Weerawarana
Other books claim to present the complete Web services platform architecture, but this is the first one I've seen that really does. The authors have been intimately involved in the creation of the architecture. Who better to write this book?
See at: Amazon.co.uk | Amazon.com |