The function works the same as @DbColumn formula. If you don't understand the function arguments, locate DbColumn in Designer's Help.
Code: Function dbColumn
( db As NotesDatabase,
viewName As String,
columnNo As Integer, flgUnique
As Boolean, flgUseReplicaID As Boolean )
As Variant
'Mbonaci, 30.08.2005.
'Function works same as @DbColumn
On Error Goto ErrHandler
Dim s As New NotesSession
Dim strDbPath As String, tmpFormula
As String
strDbPath = AdjustedFilePath( s, db )
If flgUseReplicaID Then
tmpFormula = |@DbColumn
( "" : "NoCache"; "| & db.ReplicaID
& |"; "| & viewName & |"; | & columnNo & | )|
Else
tmpFormula = |@DbColumn
( "" : "NoCache"; "| & db.Server & |" : "|
& strDbPath & |"; "| & viewName
& |"; | & columnNo & | )|
End If
If flgUnique Then
tmpFormula = |@Unique( tmpFormula )|
End If
dbColumn = Evaluate( tmpFormula )
Exit Function
ErrHandler:
Msgbox "Error in function -
dbColumn" & Chr$(10) & "Line: "
& Cstr( Erl ) & Chr$(10) &
"Err No: " & Err & ": " & Error$ End Function
Function AdjustedFilePath
( s As NotesSession, db As
NotesDatabase ) As String
'Mbonaci, 19.01.2006
'Function is used to prepare
the path for LS
dbColumn implementation.
'We need path relative to notesdata dir.
On Error Goto ErrHandler
Dim datadir As String,
fcPath As String, tmpPath As String
dataDir$ = Lcase
( s.GetEnvironmentString( "Directory", True ) )
fcPath$ = Lcase( Left
( db.FilePath, Len( datadir ) ) )
If( fcPath = datadir ) Then
'If the database is open
and on the Notes
workstation FilePath returns the complete path
'for example,
C:LotusNotesDataSubdir1Subdir2dbName.nsf
fcPath = Mid$( db.FilePath, Len( datadir ) + 2 )
AdjustedFilePath = fcPath
Elseif Instr( fcPath, "!!" ) Then
'FilePath returns the
server name (srvName!!path)
when both of these cases are true:
'FilePath is used in
an agent running on a server
'The NotesDatabase
object was not obtained
through the CurrentDatabase
property of NotesSession
tmpPath = db.FilePath
AdjustedFilePath =
Right( tmpPath, Len( tmpPath ) -
Instr( tmpPath, "!!" ) - 1 )
Else
'If the database is on a Domino server,
or closed on the Notes workstation
'FilePath returns the path relative
to the data directory (for example, subdb.nsf)
AdjustedFilePath = db.FilePath
End If
'Last we double all backslashes
AdjustedFilePath = ReplaceSubstring
( AdjustedFilePath, "", "\" )
out:
Exit Function
ErrHandler:
Msgbox "Error in function -
AdjustedFilePath" &
Chr$(10) & "Line: " & Cstr( Erl ) & Chr$(10) &
"Err No: " & Err & ": " & Error$
Resume out
End Function
Function ReplaceSubstring
( Byval theString As String,
find As String, doReplace As String )
As String
Dim pos As Integer
pos = Instr( theString, find )
Do While( pos > 0 )
theString = Left$( theString, pos - 1 )
& doReplace
& Mid$( theString, pos + Len( find ) )
pos = Instr( pos + Len( doReplace ),
theString, find )
Loop
ReplaceSubstring = theString
End Function
This works as well:
Dim varList as Variant
varList = Evaluate("@DbColumn
(" & class & ":" & cache
& ";" & server & "; " & database &
";" & view & ";" & columnNumber & ")")
Where class, cache, server, database, view, and columnNumber are variables.
Paul R.
Do you have comments on this tip? Let us know. Related information from SearchDomino.com:
This tip was submitted to the SearchDomino.com tip library by member Marko B. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.
This was first published in February 2006