B
B
bamond2015-07-10 12:05:57
Asterisk
bamond, 2015-07-10 12:05:57

How to correctly compose a logical expression in an asterisk?

Good afternoon
, there is such a macro:

exten => s,n,GotoIf($[$["${ARG1}" != "exten"]|$["${ARG1}" != "out"]]?return)
exten => s,n,...................
exten => s,n,...................
exten => s,n,...................
exten => s,n(return),Return()

In theory, it should be: if arg1 is NOT exten OR arg1 is NOT OUT then go to return ...
IF ARG1 is EXTEN or OUT then continue executing the macro in normal mode ...
But in the end it turns out as if a logical operator was specified in the expression And ...
i.e. at the moment, the macro always goes into return.
Please tell me how to correctly compose a macro using logic: If ARG1 = EXTEN or ARG1 = OUT then
PS This macro will work fine:
exten => s,n,GotoIf($["${ARG1}" != "exten"]?return)
exten => s,n,...................
exten => s,n,...................
exten => s,n,...................
exten => s,n(return),Return()

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Marat Yuldashev, 2015-07-10
@bamond

As the official manual says, it is correct to do this:
But, if you can’t do this, then you can always do just two conditions:

exten => s,n,GotoIf($["${ARG1}" != "exten"]?return)
exten => s,n,GotoIf($["${ARG1}" != "out"]?return)
exten => s,n,...................
exten => s,n,...................
exten => s,n,...................
exten => s,n(return),Return()

V
Vladimir, 2015-07-10
@rostel

exten => s,n,GotoIf($["${ARG1}" != "exten" | "${ARG1}" != "out"]?return)

D
Drill, 2015-07-11
@Drill

У Вас оператор "ИЛИ". Поэтому, если результатом проверки первого условия будет "ИСТИНА", то до проверки второго условия не дойдет. Хотите, чтобы проверялись оба условия, используйте оператор "И".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question