从集合中除去项

动词:clear

从“列表”、“堆栈”或“队列”类型集合中或从“消息队列”中除去所有项。

集合是可使用索引和键进行访问的可枚举数据结构。

语法

clear --collection(ICollection<Variant>)

输入

脚本 设计器 必需的 AcceptedTypes 描述
--collection 集合 必需的 ICollection<Any> 要除去其中项的集合或“消息队列”。
在此参数中,除了“列表”、“堆栈”和“队列”类型集合外,还接受“消息队列”类型(通过连接到队列提供程序来获取)。 因此,要处理类型为“消息队列”的变量,必须从命令获取队列的参数已获取队列中获取该变量。

示例

示例 1:使用从集合中除去项命令除去“队列”类型集合中包含的所有项,并返回空。

defVar --name itensToRemove --type Queue --innertype String --value "[Maria,Ana,Lucas,Bruno]"
clear --collection "${itensToRemove}"
logMessage --message "${itensToRemove}" --type "Info"
// The result returns an empty "Queue" collection.

示例 2:使用获取队列命令获取“消息队列”变量。然后,使用从集合中除去项命令除去“消息队列”类型集合中包含的所有项,并返回空。

defVar --name connection --type QueueConnection
defVar --name obtainedQueue --type MessageQueue
defVar --name dsdsd --type Queue --innertype String
defVar --name itemsQuantity --type Numeric
connectActiveMQ --queueprovider Training --fromconfiguration  connection=value
getQueue --connection ${connection} --fromconfiguration  --queue queueA obtainedQueue=value
clear --collection "${obtainedQueue}"

另请参阅

  • 项计数
  • 获取列表项