Approach User Support homepage Approach User Support
Answers to Frequently Asked Questions about Lotus Approach
Examples LotusScripts
Example databases
Links to other Lotus Approach support services

[Return to contents]

Example LotusScript: Getting the path of a database file

Last updated: 2 Dec 2000

You can get the current directory with the CurDir() function and the current drive with the CurDrive() function. Note that while you are using an apr on a drive E:\, the Curdrive$ could still be C:\ so you should maybe use a Chdrive before.

Another way, if the dbf are associated with your apr, is to use
TableName.Property. Eg:

Dim TN, TNF As String
TN = CurrentDocument.Tables(i).TableName 'TablesName
TNF = CurrentDOcument.Tables(i).FullName 'Full path with extension

An example of this method is the following LotusScript function was submitted by Steve Carpenter. If you know the table name it will give you the current path.

Function GetTablePath (Byval pTableName As String) As String
    ' Takes table name and returns path of first occurence of the table from tables
    ' collection, or "" if table not found.
    ' 2/9/98 sc
    GetTablePath = ""
    Dim Testname As String
    pTableName = Trim$(Ucase$(pTableName))
    Forall mTable In currentdocument.tables()
        If Instr(mTable.Tablename,":") > 0 Then
            Testname = Left$(mTable.Tablename,Instr(mTable.Tablename,":") - 1)
            Testname = mTable.Tablename
        End If
        If Ucase$(Testname) = pTableName Then
            GetTablePath = mTable.Path
            Exit Forall
    End If
    End Forall
End Function

Another example is this following Script, which will bring up a help file which is in the same folder as the current document:

Sub RunHelp
    Dim a as integer
    a = Shell("WINHELP.EXE "+currentdocument.path+"helpfile.hlp",1)
End Sub

[Return to contents]

© Copyright, JohnBrown, Trademarks, Disclaimer, Acknowledgements.