lotus-notes - 如何使用 forall 循环将 Lotus 脚本中的字符串与 (##) 连接起来?
问题描述
我想用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 中使用 @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
推荐阅读
- reactjs - 返回时不能调用没有'new'的类构造函数
- sql - 我有 100 美元的数值。当我检查 isumeric 它返回为 1 但我需要将其视为 varchar 值
- initialization - 快速提问:如何初始化选择列表的 LIST-ITEM-PAIRS?
- javascript - Firebase 用户在登录或注册后变得未定义
- rust - 有没有办法在 Rust 中实现具有不同通用约束的相同结构的特征?
- .net - .Net Core 身份将对象作为 Id(来自 User 类)返回,但我需要字符串(MongoDB 是我的数据库)
- c# - 如何在 Azure 函数应用中调用函数后动态更改内容
- nuxt.js - 有没有办法减少 nuxt 入口点包的大小?
- java - 在 Sping Batch 中通过 JsonItemReader 读取内容后删除 json 文件
- java - 尝试从 Java 中存在模式偏差的数千个 JSON 文件中提取数据