Hi,
I have a little problem, I have to arrays
Dim array1 (0 to 3) As String, array2 (0 to 3)
As String
array1 (0) = “Mike Woo”
array1 (1) = “Bill clinton”
array1 (2) = “George bush”
array1 (3) = “James Smith”
array2 is changed after the user saved the form.
array2 (0) = “Bill clinton”
array2 (1) = “Matt Woo”
array2 (2) = “George bush”
array2 (3) = “William Smith”
the logic below is not working…
Dim aTemp As String, aTemp1 As String
aTemp1 = ""
aTemp = ""
For x = 1 To Ubound(array1)
aTemp = array1(x)
For y = 1 To Ubound(array2)
If (aTemp <> array2(y)) Then
aTemp1 = aTemp1 + aTemp
End If
Next
Next
How do I get the list (array of string) of differences between these two arrays?
thanks,
Mike Woo
Subject: How do I get the list (array of string) of differences between these two arrays?
How about something like this…Create a hidden field on the form and use the following formula,
Field1:
Field2:
Field3: …uses formula: @ReplaceSubstring(fieldtwo;fieldone;“”)
Field3 will show differences!
Subject: one minor omission
you forgot @trim:
@trim(@ReplaceSubstring(field2; field1; “”))
Subject: How do I get the list (array of string) of differences between these two arrays?
Hi,
Can you not use ArrayReplace to achieve your objective? Something like this.
Dim array1 (0 To 3) As String, array2 (0 To 3) As String
array1 (0) = "Mike Woo"
array1 (1) = "Bill clinton"
array1 (2) = "George bush"
array1 (3) = "James Smith"
array2 (0) = "Bill clinton"
array2 (1) = "Matt Woo"
array2 (2) = "George bush"
array2 (3) = "William Smith"
firstlist = Arrayreplace(array1, array2, "")
nextlist = Arrayreplace(array2, array1, "")
newlist = Arrayappend(firstlist, nextlist)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Call doc.ReplaceItemValue("abc", Fulltrim(newlist))
Subject: Thank you. I got it!
Thank you. I got it!
Subject: If it has to be done with script…
here’s an example you can modify.
’ script compares values in one field to that of another field then writes the differences to a named field
Dim session As New notessession
Dim db As notesdatabase
Dim doc As NotesDocument
Dim item, item2, item3 As NotesItem
Dim list1( 1 To 10 ) As String
Dim list2( 1 To 10 ), test As String
Dim count, count2, x, m As Integer
'gets the first document (doc) and the value from field
Set db = session.currentdatabase
Set doc = session.documentcontext
Set item = doc.GetFirstItem( "ula" )
count = 1
Forall v In item.Values
list1( count ) =v
'Messagebox "Field1 = " & v ' this is simply a check to see the values
count = count + 1
End Forall
count = count -1
'get the next documents and their values
Set item2 = doc.GetFirstItem( "ulb" )
Set item3 = doc.GetFirstItem("ulc")
count2 = 1
Forall y In item2.Values
list2( count2 ) = y
'Messagebox "Field2 = " & y ' this is simply a check to see the values
count2 = count2 + 1
End Forall
count2 = count2 -1
'compare the two fields, if true do nothing, if false, write value(s) to the named field
For x = 1 To count
test = "false"
For m = 1 To count2
If (list1(x) = list2(m)) Then
test = "true"
Exit For
End If
Next
For m = 1 To count2
If (list1(x) <> list2(m)) Then
If test = "false" Then
Messagebox list1(x) & " is missing." ' this is simply a check to see the values
Call item3.appendtotextlist(list1(x))
Call doc.save(True, False)
'### the next three fields are not used; however if a document for each value was needed, this would do it
'Set doc3 = db.createdocument
'doc3.form = "list"
'doc3.fieldthree = list1(x)
'Call doc3.save(True,True)
Exit For
End If
End If
Next
Next