I am having problems with an agent slowing down considerably when it runs code using the Ubound function, especially with larger documents (>2meg). When this happens, the agent that normally runs in minutes takes hours. Can you give me any suggestions on what to do to get better perfomance? My subroutine follows:
Sub outputDocument (theHandle As Integer, theOutputDoc As NotesDocument, theColumnIdx As Integer, theDelimiter As String,theOutDocFileName As String)
Dim i As Long
Dim j As Long
Dim k As Long
Dim delim As String
Dim s As String
Dim itm As NotesItem
On Error Goto HandleOutDocErr ' error handling to trap file already open error - jrj 05/12/05
If Debug > 1 Then Print "+outputDocument "+Str$(Loc(theHandle)) ' added file position to debug msg - jrj 05/12/05
' debug msg - jrj 05/13/05
If Debug > 1 Then
Print "+outputDocument.theOutputDoc.LineIdx(0) "+Str$(theOutputDoc.LineIdx (0))
Print "+outputDocument.theOutputDoc.theColumnIdx "+Str$(theColumnIdx)
End If
For i = 0 To theOutputDoc.LineIdx (0)
For j = 0 To theColumnIdx
Set itm = theOutputDoc.GetFirstItem ("Column" & Cstr (j+1))
'change to reduce references to itm.Values - jrj 05/13/05
If i > Ubound (itm.Values) Then
s = itm.Values (Ubound (itm.Values))
Else
s = itm.Values (i)
End If
If j < theColumnIdx Then
delim = theDelimiter
Else
delim = Chr$ (13) & Chr$ (10)
End If
Print #theHandle, s & delim;
Next
If Debug > 1 Then
If Loc(theHandle) >= 114688 Then ' dont print this debug unless at least 14mb has been written
Print "-outputDocument.end of j loop "+Str$(Loc(theHandle)) ' jrj 05/13/05
End If
End If
Next
' close and reopen output file to prevent File Already Open error - jrj 05/12/05
Close theHandle
Open theOutDocFileName For Append As theHandle
If Debug > 1 Then Print "-outputDocument "+Str$(Loc(theHandle)) ' added file position to debug msg - jrj 05/12/05
Exit Sub