LotusScript version of @DbColumn


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 & | )|
        tmpFormula = |@DbColumn
( "" : "NoCache"; "| & db.Server & |" : "| 
& strDbPath & |"; "| & viewName 
& |"; | & columnNo & | )|        
    End If
    If flgUnique Then
        tmpFormula = |@Unique( tmpFormula )|
    End If
    dbColumn = Evaluate( tmpFormula )
    Exit Function
    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, 
        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 )
        '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, "", "\" )
    Exit Function
    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 )
    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:

  • LotusScript Learning Guide
  • LotusScript FAQ
  • Reference Center: LotusScript tips and resources

    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

  • There are Comments. Add yours.

    TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

    REGISTER or login:

    Forgot Password?
    By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
    Sort by: OldestNewest

    Forgot Password?

    No problem! Submit your e-mail address below. We'll send you an email containing your password.

    Your password has been sent to:

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.