I needed to be able to report multiple values rather than just element zero of an item. I modified the agent so that:
a. for fields which have multiple values, all values are displayed
b. "$" fields are ignored
c. implemented error trapping
Changes made to the following function only in the agent Compare Documents.
Sub GetFieldValues
On Error Goto errHandler
Dim positionOfChar As Integer
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL, 4)
Forall itemName In uniqueList
positionOfChar = Instr(itemName, "$")
If positionOfChar <> 1 Then
'Column 1 --> Field Name
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText(itemName)
Call rtitem.EndInsert
'Column 2 --> Value in Document 1
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
If doc1.HasItem(itemName) Then
tmp1 = doc1.GetItemValue(itemName)
len1 = Ubound(tmp1) +1
Forall t1 In tmp1
x = x + Cstr(t1)
count1 = count1 + 1
If len1 > 1 Then
If count1 < len1 Then
x= x+", "
End If
End If
End Forall
Call rtitem.AppendText(Cstr(x))
Else
Call rtitem.AppendText("-Field Not Found-")
End If
Call rtitem.EndInsert
x = ""
count1 = 0
'Column 3 --> Value in Document 2
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
If doc2.HasItem(itemName) Then
tmp2 = doc1.GetItemValue(itemName)
len2 = Ubound(tmp2)+1
Forall t2 In tmp2
y = y + Cstr(t2)
count2 = count2 + 1
If len2 > 1 Then
If count2 < len2 Then
y= y+", "
End If
End If
End Forall
Call rtitem.AppendText(Cstr(y))
Else
Call rtitem.AppendText("-Field Not Found-")
End If
Call rtitem.EndInsert
y = ""
count2 = 0
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
End If
End Forall
exitGracefully:
Exit Sub
errHandler:
Msgbox "Error at line: " + Cstr(Erl) + ", in agtCompareDocs (Agent)"
Resume exitGracefully
End Sub