如何使用 forall 循环将 Lotus 脚本中的字符串与 (##) 连接起来?

How to concatenate a string in lotus script with (##) with forall loop?

我想用 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 都是单独的文件名

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

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

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

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

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- 循环:

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