You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.
TSL sequence
Use this operator to add a sequence-number to each instance in a set of instances.
Note: The sequence operator returns the sequence-number of the FOREACH loop that it is used in. It is not the sequence in which the instances where created. The sequence number starts at 0.
Syntax
[[[#]]]
Input
- # is the sequence operator
Example
Suppose you want to create an overview of all registered users. Then you could create the following message:
[[[FOREACH user]]][[[#]]] [[[user.last_name]]], [[[user.first_name]]][[[/FOREACH]]]
If you have three registered users: John Doe, Jane Doe and Mr X your user list would look like this: 0 Doe, John 1 Doe, Jane 2 X, Mr
Or you want to create a comma separated list that contains all users:
[[[FOREACH user]]] [[[user.first_name]]] [[[user.last_name]]] [[[IF # != (COUNT user.last_name) - 1]]], [[[ELSE]]]. [[[/IF]]] [[[/FOREACH]]] /*end user loop*/
Than the result would look like this:
John Doe, Jane Doe, Mr X.