Examples: GetNthDocument method (NotesView - LotusScript®)

This agent performs a full-text search on the Botanist's Delight folder in the current database. It then removes the second document in the collection from the folder.

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim folderName As String
  Dim view As NotesView
  Dim count As Integer
  Dim doc As NotesDocument
  Set db = session.CurrentDatabase
  folderName = "Botanist's Delight"
  Set view = db.GetView( folderName )
  count = view.FTSearch( "pollution", 0 )
  If count >= 2 Then
    Set doc = view.GetNthDocument(2)
    Call doc.RemoveFromFolder( folderName )
    Call view.Clear
    Messagebox "Number found: " & count, , _
    "No documents removed"
  End If
End Sub