【问题标题】:How to concatenate a string in lotus script with (##) with forall loop?如何使用 forall 循环将 Lotus 脚本中的字符串与(##)连接起来?
【发布时间】:2020-05-04 09:21:45
【问题描述】:

我想用 forall 循环连接具有多个值的字符串 这是代码:

varAttachmentNames = Evaluate( "@AttachmentNames" , doc )
Forall strAttachmentName in varAttachmentNames
    Set object = doc.GetAttachment( strAttachmentName )
    fileName = object.Name
End Forall

如果有多个文件,我希望在循环结束时将名称命名为 abc.pdf##xyz.pdf 两者都是文件名中的单独文件名 abc 和 xyz(字符串变量)

【问题讨论】:

  • 只要你想使用 Evaluate 函数,你可以在这里连接:Evaluate( {@Implode( @AttachmentNames , "##")} , doc )

标签: lotus-notes lotusscript domino-designer-eclipse


【解决方案1】:

有很多可能性,有些甚至不需要 LotusScript-Loop:

首先:已经在公式中进行连接:

Dim strResult as String
varAttachmentNames = Evaluate( {@Implode( @AttachmentNames , "##")} , doc )
strResult = varAttachmentNames(0)

第二:在 LotusScript 中使用 @Implode- 对应物:

Dim strResult as String
varAttachmentNames = Evaluate( "@AttachmentNames" , doc )
strResult = Implode( varAttachmentNames, "##" )
' or with the (in other programming languages) more common alias "Join": 
'strResult = Join( varAttachmentNames, "##" )

第三:使用你的 Forall-Loop:

Dim strResult as String
varAttachmentNames = Evaluate( "@AttachmentNames" , doc )
Forall strAttachmentName in varAttachmentNames
    Set object = doc.GetAttachment( strAttachmentName )
    fileName = object.Name
    If strResult = "" then
        strResult = fileName
    Else
        strResult = strResult & "##" & fileName
    End If
End Forall

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 2017-06-01
    • 2020-07-31
    • 1970-01-01
    • 2011-05-13
    • 1970-01-01
    相关资源
    最近更新 更多