IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Technical Library
developerWorks

[back to An alternative to the OpenServer URL command]

Open Server agent
Here is the complete code for the Open Server agent:

Class DirList
    Public level As Integer
    Public prefix As String
    Public entries List As String
End Class

Sub Initialize
'
' Certain system databases are hidden by OpenServer.
' We list these databases here. You can modify
' this list if you want.
    Dim hidden List As String
    hidden("admin4.nsf") = ""
    hidden("busytime.nsf") = ""
    hidden("setup.nsf") = ""
'
' Create a list of databases on the server
'
    Dim pathmap List As DirList
    Set session = New NotesSession
    Set dbdir = session.GetDbDirectory("")
    Set db = dbdir.GetFirstDatabase(DATABASE)
    While Not (db Is Nothing)
      filePath = db.FilePath
' Check if this database is supposed to be hidden
      If (Iselement(hidden(filePath))) Then Goto NextDb
' Change Windows backslashes to forward slashes
      While (Instr(filePath,"\") > 0)
        Mid(filePath,Instr(filePath,"\")) = "/"
      Wend
' Get actual subdirectory path (everything before the file name)
      path = Strleftback(filePath,"/")
' Normalize the path to start and end with a slash
      If path = "" Then path = "/" Else path = "/" & path & "/"
      If Not Iselement(pathmap(path)) Then
' Add this path to the directory list
        Set pathmap(path) = New DirList
        Set subdir = pathmap(path)
        subdir.level = 0
        subdir.prefix = ""
' Determine how many levels deep this path is
        segment = Instr(path,"/")
        While (segment > 0)
          subdir.level = subdir.level + 1
          If subdir.level > 1 Then subdir.prefix = subdir.prefix & ". . "
          segment = Instr(segment + 1,path,"/")
        Wend
      End If
      Set subdir = pathmap(path)
' Save the name to be displayed for this database
      If (db.Title <> "") Then
        subdir.entries(db.FileName) = db.Title
      Else
        subdir.entries(db.FileName) = "(No title: " & db.FileName & ")"
      End If
NextDb:
      Set db = dbdir.GetNextDatabase
    Wend

'
' Generate HTML, looping over directories in sort order
'
    Set server = New NotesName(session.CurrentDatabase.Server)
    Print "<h2>"; server.Abbreviated; "</h2><ul>"
    Do
' Search the directory list for the lowest-sorting path
      lowest = ""
      Forall p In pathmap
        If lowest = "" Then
          lowest = Listtag(p)
        Elseif Listtag(p) < lowest Then
          lowest = Listtag(p)
        End If
      End Forall
      If lowest = "" Then Exit Do ' no entries left in list, so we're done
      Set subdir = pathmap(lowest)
      If subdir.level > 1 Then
' Generate HTML for subdirectory name
        Print Mid(subdir.prefix,4);
        Print {<img src="/icons/afolder.gif" border=0>};
        Print Strright(lowest,"/",5,subdir.level - 1);{<br>}
      End If
' Generate HTML for all entries in the database list for this path
      Forall e In subdir.entries
        Print subdir.prefix;
        Print {<img src="/icons/abook.gif" border=0><a href="};
        Print lowest;Listtag(e);{?OpenDatabase">};e;{</a><br>}
      End Forall
' Done with this path, get it out of the list
      Erase pathmap(lowest)
    Loop

    Print "</ul>"
End Sub
    About IBM Privacy Contact