Foreach - Snom 4S Administrator's Manual

Sip proxy/registrar version 2.30
Table of Contents

Advertisement

[
S N O M
The comparisons for conditions is done case-insensitive, so that
"TRUE" also leads to execution of a body.
Note: In contrast to C, the body must be enclosed in brackets ("{"
and "}"), even if you have only one statement inside of the brackets.
Example:
if ($a == "17") {
log("Found a\n");
}
else if ($b == "17") {
log("Found b\n");
}
else if ($c == "17") {
log("Found c\n");
}
else {
log("Not found\n");
}

foreach

The proxy does not support looping. This was done to avoid
endless loops. Endless loops are catastrophic for the proxy as it sill stop
service in such a case.
The alternative of looping is going through lists. Lists always have
a defined length and there is no danger that the proxy will end up in an
endless loop.
The foreach command has the following syntax:
foreach(variable, list) { body }
The proxy will assign every element of the list to the provided
variable and execute the body. The scope of the variable of the current
context, that means the value of the variable after the foreach statement
will be the value of the last list element (if there was at least one
list element) or the variable will be unchanged (if there was no list
element).
The list is an expression that is evaluated before the execution of
the foreach statement starts. The result of the execution is interpreted as
string which contains the list elements separated by space.
Example:
36 • Scripting
4 S P
/ R
R O X Y
E G I S T R A R
M
]
A N U A L

Advertisement

Table of Contents
loading

Table of Contents