Examples: FTSearchRange method (NotesDatabase- LotusScript®)

This agent returns all the documents in the current database that contain a user-specified string, in groups of eight.

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Set db = session.CurrentDatabase
  REM Update full-text index
  Call db.UpdateFTIndex(True)
  REM Get query and put in quotes
  query$ = Inputbox("Enter string to search for", "Query")
  If query$ = "" Then Exit Sub
  query$ = """" & query$ & """"
  REM Get the first 8 documents that match the query
  start& = 1
  Set dc = db.FTSearchRange( query$, 8, _
  FT_SCORES, FT_STEMS, start&)
  While dc.Count > 0
    REM Display Subject for documents matching query
    Set doc = dc.GetFirstDocument
    While Not(doc Is Nothing)
      message$ = message$ & doc.Subject(0) & Chr(10)
      Set doc = dc.GetNextDocument(doc)
    Wend
    Messagebox message$,, _
    "Search results " & start& & " - " & start& - 1 + dc.Count
    REM Get next 8 documents that match the query
    message$ = ""
    start& = start& + 8
    Set dc = db.FTSearchRange(query$, 8, _
    FT_SCORES, FT_STEMS, start&)
  Wend
End Sub