Count Items

Verb: count

Counts the number of items in a collection such as a "List", "Stack", "Queue" or "Message Queue".

Collections are enumerable data structures that can be accessed using indexes and keys.

Syntax

count --collection(ICollection<Variant>) (Numeric)=value

Inputs

Script Designer Required AcceptedTypes Description
--collection Collection Required ICollection<Any> Collection with the items to be counted.
In this parameter, in addition to “Queue” and "Stack" and "List" collections, the “Message Queue” type, which originates from the connection to a queue provider, is also accepted. To manipulate a “Message Queue” variable, it must be obtained from the Queue Obtained parameter of the Get Queue command.

Outputs

Script Designer AcceptedTypes Description
value Itens Quantity Number Returns the number of items in the collection or in a "Message Queue".

Example

Example 1: The command counts the number of items in a "Queue" type collection.

defVar --name namesCollection --type Queue --innertype String --value "[Ana,Maria,Lucas,Victor]"
defVar --name amountOfNames --type Numeric
count --collection "${namesCollection}" amountOfNames=value
logMessage --message "${amountOfNames}" --type "Info"
//The result of ${namesQuantity} after execution is: 4.

Example 2: The Count Items command counts the number of items in a "Message Queue" variable, obtained from the connection to a queue provider.

defVar --name connection --type QueueConnection
defVar --name obtainedQueue --type MessageQueue
defVar --name itensQuantity --type Numeric
connectActiveMQ --queueprovider Training --fromconfiguration  connection=value
getQueue --connection ${connection} --fromconfiguration  --queue queueA obtainedQueue=value
count --collection "${obtainedQueue}" itensQuantity=value

See Also

  • Get List Item
  • Remove Items from Collection