Discussion:
[SR-Users] Condition Statements - How many levels
Joel White
2014-07-16 12:46:24 UTC
Permalink
I was wondering how many levels deep in conditional _if_ _else_
statements can go. I need to create a statement that has 4 possible
outcomes and need to know if this is possible.

I have two variables

I want one thing to happen if only the first variable is present

Another if only the second variable is present

Yet another if they are both present

And a fail over if None of the variables are present



I do see that is can be done with 3 conditions using _if_ _if else_
_else_

how can I accomplish 4 conditional statements?


Thank you in advance

Joel
Brandon Armstead
2014-07-16 20:37:11 UTC
Permalink
Joel,

You are looking for something like this logically:

if(!($var(is_a_present) == $null && $var(is_b_present))){
# a and b exist
} else if(!($var(is_a_present) == $null){
# a exists
} else if(!($var(is_b_present) == $null)){
# b exists
} else {
# failover
}

Sincerely,
Brandon Armstead
Post by Joel White
I was wondering how many levels deep in conditional _if_ _else_
statements can go. I need to create a statement that has 4 possible
outcomes and need to know if this is possible.
I have two variables
I want one thing to happen if only the first variable is present
Another if only the second variable is present
Yet another if they are both present
And a fail over if None of the variables are present
I do see that is can be done with 3 conditions using _if_ _if else_
_else_
how can I accomplish 4 conditional statements?
Thank you in advance
Joel
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Brandon Armstead
2014-07-16 20:38:05 UTC
Permalink
Joel,

Forgot second half of initial if

if(!($var(is_a_present) == $null && $var(is_b_present) *== $null)*){
# a and b exist
} else if(!($var(is_a_present) == $null){
# a exists
} else if(!($var(is_b_present) == $null)){
# b exists
} else {
# failover
}
Post by Brandon Armstead
Joel,
if(!($var(is_a_present) == $null && $var(is_b_present))){
# a and b exist
} else if(!($var(is_a_present) == $null){
# a exists
} else if(!($var(is_b_present) == $null)){
# b exists
} else {
# failover
}
Sincerely,
Brandon Armstead
Post by Joel White
I was wondering how many levels deep in conditional _if_ _else_
statements can go. I need to create a statement that has 4 possible
outcomes and need to know if this is possible.
I have two variables
I want one thing to happen if only the first variable is present
Another if only the second variable is present
Yet another if they are both present
And a fail over if None of the variables are present
I do see that is can be done with 3 conditions using _if_ _if else_
_else_
how can I accomplish 4 conditional statements?
Thank you in advance
Joel
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Continue reading on narkive:
Loading...