The script uses an array of type NotesAgent, arbitrarily declared to be ten elements, to hold the agents that are disabled and owned by the current user.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agentArray( 1 To 10 ) As NotesAgent
Dim count As Integer
Dim r As String
Set db = session.CurrentDatabase
count = 0
' find agents owned by current user and disabled
Forall a In db.Agents
If ( a.Owner = session.UserName ) And _
Not ( a.IsEnabled ) Then
count = count + 1
Set agentArray( count ) = a
End If
End Forall
r = Inputbox$( "You have " & count & _
" disabled agents. Delete them?" )
If ( r = "yes" ) Or ( r = "y" ) Then
' go through each agent that's owned by current
' user and disabled
Forall b In agentArray
Call b.Remove
End Forall
End If
End Sub