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,$LAST_SEPARATOR,$OUTPUT_STRING)
listtostr($LIST,$SEPARATOR,$OUTPUT_STRING)
listtostr arguments
Argument | Mode | Type | Description |
---|---|---|---|
| Input | LIST | The original list that you want to convert into a string |
| Input | STRING | Specifies the separator that you want between the elements in the list after the list is converted to a string |
| Input | STRING | (Optional) Specifies the last separator to be input before the final list element in the resulting 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:
$EV.msg = strreplace($EV.msg,' ','_')
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:
'a1 and b1 | a2, b2 and c2 | a3, b3, c3 | a4 or b4 | a5 | | a6, b6'
Comments
Log in or register to comment.