Domino Code Fragment

Code Name*
Compact all local databases < 90% utilized
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.217.210.147
Description*
Checks all databases Locally and Compacts those that are less than 90% utilized.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Sub Initialize
    Dim session As New NotesSession    
    Dim dbase As NotesDatabase
    Dim directory As New NotesDBDirectory("")
    Dim Status As Long
    Dim nlog As New NotesLog("Compact Utility")
   
    Call nlog.OpenMailLog(session.username,"DB Compact Utility")
   
    Set dbase = directory.GetFirstDatabase(Database)
    Call dbase.Open("",dbase.FileName)
    On Error Resume Next
    While Not (dbase Is Nothing)
         
         If dbase.PercentUsed < 90 Then
              status = dbase.Compact
              If Err = 4005 Then
                   Call nlog.LogAction(dbase.FileName & " is in " _
                   & "use")
                   Err = 0
              Else
                   Call nlog.LogAction("Compacted " & _
                   dbase.FileName)
              End If
         Else
              Call nlog.LogAction("Database " & dbase.FileName & _
              " already " & dbase.PercentUsed & " Percent Used")
         End If
         
         Call dbase.Close()

          Set dbase = directory.GetNextDatabase()
         Call dbase.Open("",dbase.filename)
    Wend
    Call nlog.close
    Messagebox ("Finished Compacting")
End Sub