Conditions in dialplan

Hi!

How can I check if a string is empty in the dialplan? Is it possible to include different conditions in one “GotoIf” function? I’m trying the following and it doesn’t work:

same => n,GotoIf($["${value}" != "" ]?optionA:optionB)

it goes always to “optionB”, whether values is empty or not

I’m also trying this

same => n,GotoIf($[ $["${value}" != "" ] | $[${value_number} > 10] ]?optionA:optionB)

and it gives an error:

ast_expr2.fl:470 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ':', expecting $end; Input:

Any advice?
thanks

I use this sometimes:

GotoIf($[${LEN(${value})} < 10]?optionA)

[ Name of function corrected ]

$[${EXISTS(${value})}]

On your original, that normally should work, except possibly that you should try it without any spaces.

The thing to remember with the second one is that this is basically a macro processor ${value_number} substitutes as nothing, so what gets parsed is “> 10”. However I cannot think why it would not fault until the :. Is it possible that some characters got mangled, e.g. smart quotes, when added to the file. you should probably prefix with a 0, when doing a numeric comparison, or try a leading + sign.

3 Likes

Thanks! It’s working now!

I just had another issue combining different conditions, as I didn’t know I had to put them all inside the same brackets:
same => n,GotoIf( $[ $[${EXISTS(${value})}] | $[${value_number} > 10] ]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.