Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Entries

photo

DominoDatabase.HasRo...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     No Comments 0
photo

@GetFile & @GetFileC...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     No Comments 0
photo

DominoDocument.XML

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     No Comments 0
photo

Extending a Java Cla...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     No Comments 0
photo

XSLT Transformation ...

Blog:  .Domino Frame...
Peter Presnell
Updated 
No Ratings 0     Comments 3

Dogear Bookmarks

.Domino Framework

Blog Authors:  Peter Presnell  

Previous |  Main  | Next

LotusScript Version of @DBColumn

Peter Presnell  |     |  Tags:  @dbcolumn .dominoframework  |  Comments (0)
The .Domino Framework provides the LotusScript equivalent for many @Functions.  These can be found in the Domino.@Functions namespace.
Note: Because LotusScript does not allow the "@" character to be used for function names I have adopted the naming standard of atf (AT Function).
I have just expanded the functionality of the atfDBColumn to provide support for NotesDocumentCollections.  This may not be the most efficient way to achieve the result, but it is a very fast way to code the need to get a list of field values from a database/view/document collection - e.g. when prototyping.  The expanded atfDBColumn method provides the ability to:-
  1. Pass either a database, view, or document collection as the source.
  2. Request either the contents of a column number or fieldname to be returned.
'/**
' * Returns an array containing the list of values for a specific column/field for any collection of documents
' *
' * @author Peter Presnell
' * @param ClassCache Not used
' * @param Database NotesDatabase object, server/filepath, or replicaid id, or Nothing (current database)
' * @param View NotesDocumentCollection, NotesView, name of view, or Nothing (All documents in database)
' * @!param Column Column number or name of field corresponding to values to be returned
' * @return List of values
' */
Function atfDBColumn(ClassCache As Variant, Database As Variant,View As Variant, Column As Variant) As Variant

Dim iDB As New NotesDatabase("","") ' Database to perfrom lookup
Dim iCollection As Variant ' View/Document Collection used to perfrom lookup
Dim EntryList As NotesViewEntryCollection ' List of all entries in view
Dim Entry As NotesViewEntry ' Current entry in view
Dim Doc As NotesDocument ' Document that corresponds to current entry in view
Dim ColumnValues As Variant
Dim Results As Variant ' Interim results
Dim Index As Long ' Counter used to loop through array
Try:
On Error Goto Catch

' Setup database/view

Redim Results(0)
Select Case Typename(Database)
Case "NOTESDATABASE"
Set iDB = Database
Case "STRING"
Call iDB.OpenByReplicaID(Session.CurrentDatabase.Server,Cstr(Database))
Case "STRING ()"
If (Ubound(Database) = 1) Then
If Database(1) = "" Then Set iDB = Session.CurrentDatabase Else Call iDB.Open(Database(0),Database(1))
End If
End Select

Select Case Typename(View)
Case "NOTESDOCUMENTCOLLECTION"
Set iCollection = View
Case "NOTESVIEW"
Set iCollection = View
Set iDB = iCollection.Parent
Case "OBJECT"
If iDB Is Nothing Then Set iDB = Session.CurrentDatabase
Set iCollection = iDB.AllDocuments
Case "STRING"
If (iDB Is Nothing) Then Set iDB = Session.CurrentDatabase
Set iCollection = iDB.GetView(Cstr(View))
Case Else
Exit Function
End Select
If iCollection Is Nothing Then Error 1000, "View not found"

' Extract values

Select Case Typename(iCollection)
Case "NOTESDOCUMENTCOLLECTION":
Set Doc = iCollection.GetFirstDocument
While Not Doc Is Nothing
Select Case Typename(Column)
Case "INTEGER","LONG"
If (Ubound(Doc.ColumnValues) >= Cint(Column)-1) Then
ColumnValues = Doc.ColumnValues(Column-1)
If (Isarray(ColumnValues)) Then
Forall ColumnValue In ColumnValues
Redim Preserve Results(Index&)
Results(Index&) = ColumnValue
Index& = Index& + 1
End Forall
Else
Redim Preserve Results(Index&)
Results(Index&) = ColumnValues
Index& = Index& + 1
End If
End If
Case "STRING"
Redim Preserve Results(Index&)
If (Doc.HasItem(Cstr(Column))) Then
Results(Index&) = Doc.GetItemValue(Cstr(Column))(0)
Index& = Index& + 1
End If
End Select
Set Doc = iCollection.GetNextDocument(Doc)
Wend
Case "NOTESVIEW":
Set EntryList = iCollection.AllEntries
Set Entry = EntryList.getFirstEntry
While Not Entry Is Nothing
Select Case Typename(Column)
Case "INTEGER","LONG"
If (Ubound(Entry.ColumnValues) >= Cint(Column)-1) Then
ColumnValues = Entry.ColumnValues(Column-1)
If (Isarray(ColumnValues)) Then
Forall ColumnValue In ColumnValues
Redim Preserve Results(Index&)
Results(Index&) = ColumnValue
Index& = Index& + 1
End Forall
Else
Redim Preserve Results(Index&)
Results(Index&) = ColumnValues
Index& = Index& + 1
End If
End If
Case "STRING"
Redim Preserve Results(Index&)
Set Doc = Entry.Document
If (Doc.HasItem(Cstr(Column))) Then
Results(Index&) = Doc.GetItemValue(Cstr(Column))(0)
Index& = Index& + 1
End If
End Select
Set Entry = EntryList.getNextEntry(Entry)
Wend
End Select

atfDBColumn = Results
Exit Function

Catch:
Stop
Call ReportError
Exit Function

End Function

Comments

Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.