AI Object
 
Syntax
 
lValue = AI.ConversationCount
 
Type
Long
Access
read-only
Description
Returns the number of conversation handles that are currently open on the AI object. The counter is incremented by NewConversation (and by Ask when it creates an implicit handle), and decremented by CloseHandle. CloseAll resets it to zero.
 
Use this property to detect leaked handles in long-running macros or in server-side hosts such as MacroHandler. A macro that processes a batch of records and opens a fresh conversation per record should see ConversationCount return to its baseline after each iteration; a steadily growing value indicates that CloseHandle is being skipped on some code path.
 
See Also
Example
 
Sub Main
Dim hConv As Long
Dim iRow As Integer
 
Debug.Print "<span style='color: #004080; font-weight: bold;'>Open</span> before: "; AI.ConversationCount
 
For iRow = 1 To 10
hConv = AI.Ask("Process row " & iRow, aiGeneral)
Do : DoEvents : Loop Until AI.GetStatus(hConv) <> aiStatusBusy
AI.CloseHandle hConv
Next iRow
 
Debug.Print "<span style='color: #004080; font-weight: bold;'>Open</span> after: "; AI.ConversationCount
End Sub