IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  Lotus Sandbox

Lotus Sandbox

developerWorks
User Review of Agent to Compare 2 Documents in R5
Submitted by Lee P Ward on 11/03/2000.
Rating: 3 stars
The original code only checked for items that were in the first document. This code needed to be expanded to check for fields that exist in either document, and give the values for those fields in both documents, if different. Here is the code that I used. You will also need to create a form called "TextInput" with a layout region and a multivalued field called "DisplayText" that displays multiple values as new lines.
Sub Initialize
Dim session As New notessession
Dim ws As New notesuiworkspace
Dim db As notesdatabase
Dim uiview As notesuiview
Dim coll As notesdocumentcollection
Dim firstdoc As notesdocument
Dim seconddoc As notesdocument
Dim newdoc As notesdocument
Dim Item1 As notesitem
Dim Item2 As notesitem
Dim differences As String
Dim x As Integer
Dim rt1, rt2 As NotesRichTextItem


' *** Only for R5 clients
Dim version As String
Dim extract As String
version = session.NotesVersion
extract = Left(version, 9)
If extract <> "Release 5" Then
Messagebox "Important: Sorry, but this agent can only be used by an R5 client.", 0 + 64, "Sorry!"
Exit Sub
End If

Set db = session.currentdatabase
Set uiview = ws.currentview
Set coll = db.unProcessedDocuments

If coll.count < 2 Then
Messagebox "This process is designed to compare 2 documents",16,"Please select 2 documents"
Exit Sub
End If

' *** Get the 1st 2 selected docs, ignoring the rest
Set firstdoc = coll.getfirstdocument
Set seconddoc = coll.GetNextDocument( firstdoc )
Set newdoc = New NotesDocument (db)
'newdoc.Form = "TextInput"
Call firstdoc.CopyAllItems( newdoc, True )
Call seconddoc.CopyAllItems( newdoc, True )

' *** Loop through the fields on the documents
Forall i In newdoc.Items

If Not i.Type = 1 Then ' ********* Text (or numeric) fields
Set Item1 = firstdoc.getfirstitem(i.name)
Set Item2 = seconddoc.getfirstitem(i.name)

If Not Item2 Is Nothing Then
If Not Item1 Is Nothing Then
If Item1.valuelength > 0 Then
If Strcompare(Cstr(Item2.values(x)),Cstr(Item1.values(x)), 0) Then
differences = differences + i.name & ": First Value = (" & Cstr(Item1.values(x)) & ")" & Chr(10) & i.name & ": 2nd Value = (" & Cstr(Item2.values(x)) & ")"& Chr(10) & Chr(10)
End If
End If
Else
differences = differences + i.name & ": First Value = (No field of this name)" & Chr(10) & i.name & ": 2nd Value = (" & Cstr(Item2.values(x)) & ")"& Chr(10)& Chr(10)
End If
Else
differences = differences + i.name & ": First Value = (" & Cstr(Item1.values(x)) & ")" & Chr(10) & i.name & ": 2nd Value = (No field of this name)" & Chr(10)& Chr(10)
End If

Else ' ******** Rich Text
Set rt1 = firstdoc.getfirstitem(i.name)
Set rt2 = seconddoc.getfirstitem(i.name)

If Not rt2 Is Nothing Then
If Not rt1 Is Nothing Then
If rt1.valuelength > 0 Then
If Strcompare(Cstr(rt2.GetFormattedText(False, 70)),Cstr(rt1.GetFormattedText(False, 70)), 0) Then
differences = differences + i.name & ": First Value = (" & Cstr(rt1.GetFormattedText(False, 70)) & ")" & Chr(10) & i.name & ": 2nd Value = (" & Cstr(rt2.GetFormattedText(False, 70)) & ")"& Chr(10)& Chr(10)
End If
End If
Else
differences = differences + i.name & ": First Value = (No field of this name)" & Chr(10) & i.name & ": 2nd Value = (" & Cstr(rt2.GetFormattedText(False, 70)) & ")"& Chr(10)& Chr(10)
End If
Else
differences = differences + i.name & ": First Value = (" & Cstr(rt1.GetFormattedText(False, 70)) & ")" & Chr(10) & i.name & ": 2nd Value = (No field of this name)" & Chr(10)& Chr(10)
End If
End If
End Forall
If differences = "" Then
differences = "There were no differences between these two documents"
End If
newdoc.DisplayText = differences
'Messagebox differences,0,"Comparison Results"
flag = ws.DialogBox( "TextInput" , True, True , True , True, True , False, "Comparison Differences" , newdoc,, )

End Sub

Go back

Lotus Software

Document options
Print view

  Sandbox views
By Application Name
By Category
By Product
By Audience
By Date
By Submitter
Conferences

  Resources
developerWorks: Lotus Downloads
alphaWorks Downloads
    About IBM Privacy Contact