listtostr—convert a list of strings into a single string
The listtostr function converts a list of strings into a single string. The syntax for listtostr function is as follows:
listtostr($LIST,$SEPARATOR,$OUTPUT_STRING)
listtostr arguments
Argument | Mode | Type | Description |
---|---|---|---|
$LIST | Input | LIST | The original list that you want to convert into a string |
$SEPARATOR | Input | STRING | Specifies the separator that you want between the elements in the list after the list is converted to a string |
$LAST_SEPARATOR | Input | STRING | (Optional) Specifies the last separator to be input before the final list element in the resulting string |
$OUTPUT_STRING | Output | STRING | Displays the result after the list of strings is converted into a single string |
Use the listtostr to produce $OUTPUT_STRING from a list of strings ($LIST), with the list elements separated in the resulting string by the specified separator ($SEPARATOR).
If wanted, you can specify a unique separator ($LAST_SEPARATOR) to separate the final two list elements in the resulting string.
listtostr example
The following input:
new ADV_TestRule:
EVENT($EV) where [
$EV.mc_tool_class == "ADV"
]
triggers
{
listtostr([a1,b1],', ', ' and ', $TEST1);
listtostr([a2,b2,c2],', ', ' and ', $TEST2);
listtostr([a3,b3,c3],', ', $TEST3);
$TEST4=listtostr([a4,b4],', ', ' or ');
$TEST5=listtostr([a5],', ', ' or ');
$TEST6=listtostr([],', ');
$TEST7=listtostr([a6,b6],', ');
$EV.msg=listtostr([$TEST1,$TEST2,$TEST3,$TEST4,$TEST5,$TEST6,$TEST7],'
| ');
}
END
mposter --q -n test -a EVENT -b "mc_tool_class=ADV"
mquery -q -n test -w 'mc_tool_class: == ADV' -s msg -f
quoted
results in the following string: