Examples: IsReadOnly property (NotesStream - LotusScript®)

This agent opens a stream for a file and writes to it. If the file is read-only, the agent exits.

%INCLUDE "lsconst.lss"
Sub Initialize
  Dim session As NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim stream As NotesStream
  Dim pathname As String
  pathname = "c:\StreamFiles\"
  Set session = New NotesSession
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  Set stream = session.CreateStream
  pathname = pathname & doc.GetItemValue("Subject")(0) & ".txt"
  If Not stream.Open(pathname, "ASCII") Then
    Messagebox pathname,, "Open failed"
    Exit Sub
  End If
  If stream.IsReadOnly Then
    Messagebox pathname,, "File is read-only"
    Exit Sub
  End If
  If stream.Bytes <> 0 Then
    If Messagebox("Do you want to abort?", _
    "File exists and has content?") = IDYES Then
      Exit Sub
    End If
    If Messagebox("Do you want to replace the old content?", _
    "Rewrite or append?") = IDYES Then
      Call stream.Truncate
      Call stream.WriteText(Chr(13) & Chr(10))
    End If
  End If
  Call stream.WriteText(doc.GetItemValue("Body")(0))
  Call stream.Close
End Sub