LOTUSSCRIPT LANGUAGE


Examples: Evaluate function and statement
' For each document in a Notes database, use a Notes macro to
' compute the average for a list of numeric entries in the
' NumberList field. Evaluate returns a Variant, and Notes
' macros return an array. In this case, the array contains only
' 1 element (element 0). For more info, see the Notes
' documentation.

Sub Click(Source As Button)
  ' The macro text must be known at compile time.
  Const NotesMacro$ = "@Sum(NumberList) / @Elements(NumberList)"
  Dim result As Variant, j As Integer
  Dim db As New NotesDatabase("", "MYSALES.NSF")
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Set dc = db.AllDocuments
  For j% =  1 To dc.Count
     Set doc = dc.GetNthDocument(j%)
     result = Evaluate(NotesMacro$, doc)
     MessageBox("Average is " & result(0))
  Next
End Sub

See Also