Lotus Notes:无法访问 lotuscript 中的属性文件

Lotus Notes : Not able to access properties file in lotuscript

嗨,朋友们,我想从指定路径的机器访问属性文件。对于 java Agent,我使用了 Properties 方法并从属性文件中提取了数据。但现在我希望它在 lotuscript 中完成。我尝试使用属性方法,但它没有用,所以我想用下面的代码读取属性。

'Dim ColFileName As String
    'ColFileName="C:\abcd.properties"
    Open ColFileName For Input As 1
    Do While Not EOF(1)
    Line Input #1,txt$
    MsgBox "TEXT FILE:"+txt$ 

在属性文件中,我将其写为 col=开始

我想在 java 中使用 getProperty 方法获取 col 的 属性,方法与 lotusscript 相同。 我添加了上面的代码,但它不起作用。谁能告诉我我犯了什么错误

在选项中

%Include "lserr.lss" 'This is just a list of constants.

在某处添加这些函数:

%REM
    Function fstreamOpenFile(sPath As String, bTruncate As Boolean, bConfirmExists As Boolean) As NotesStream
    <dl>
    <dt>sPath</dt><dd>Filepath of the file to be opened/created.</dd>
    <dt>bTruncate</dt><dd>Boolean. True if file is for output and any existing file should be replaced rather than appended to.</dd>
    <dt>bConfirmExists</dt><dd>Boolean. If True, and the opened file is empty, then an ErrFileNotFound error will be thrown.</dd>
    </dl>
%END REM
Function fstreamOpenFile(sPath As String, bTruncate As Boolean, bConfirmExists As Boolean) As NotesStream
    Dim session as New NotesSession     Dim stream As NotesStream

    Set stream = session.Createstream()
    If Not stream.Open(sPath) Then Error ErrOpenFailed, {Could not open file at "} + sPath + {"}
    If bConfirmExists And stream.Bytes = 0 Then Error ErrFileNotFound, {File at "} + sPath + {" is missing or empty.} 
    If bTruncate Then Call stream.Truncate()
    Set fstreamOpenFile = stream
End Function

Function fsPropertyFileValue(sFilePath As String, sPropertyName As String, sDefaultValue As String) As String
    On Error GoTo ErrorQuietly
    Dim stream As NotesStream
    Dim sLine As String
    Dim sLeft As String
    Dim iLeftLen As Integer

    Set stream = fstreamOpenFile(sFilePath, False, True)
    sLeft = sPropertyName + "="
    iLeftLen = Len(sLeft)
    Do
        sLine = stream.Readtext
        If Left(sLine, iLeftLen) = sLeft Then
            fsPropertyFileValue = Right(sLine, Len(sLine) - iLeftLen)
            Exit Function
        End If
    Loop Until stream.Iseos
ReturnDefault:
    fsPropertyFileValue = sDefaultValue
    Exit Function
ErrorQuietly:
    Print Now, Error$
    Resume ReturnDefault
End Function

(注:我没有tested/debuggedfsPropertyFileValue。注释中的html标签是因为在编辑代理或脚本库时,设计器客户端会解析和显示 HTML 标签。)

然后你可以使用fsPropertyFileValue("C:\abcd.properties", "col", "start")获取C:\abcd.properties中col 属性的值,如果失败,使用"start".