Problem with ExecIf(), Please help


I’m running Asterisk Business Edition ABE-A.2-1. I want to use ExecIf() to play a file if a certain condition is met but I keep getting an error saying that ExecIf() count (could) not find the application. The application I’m trying to use is Playback(), so I know it’s loaded. I verified that it is loaded by “CLI> show applications”.

exten => s,n,SetVar(LoopCount=1)
exten => s,n,ExecIf($[${LoopCount} <= 2]|Playback(${filename}))

Am I not using ExecIf() they way it’s designed or is something broken?
Any help would be greatly appreciated.



I figured it out. I went looking into app_while.c and noticed that I was using ExecIf() incorrectly.

The wrong way:

exten => s,n,ExecIf($[${LoopCount} <= 2]|Playback(${filename}))

The right way:

exten => s,n,ExecIf($[${LoopCount} <= 2]|Playback|${filename})

ExecIf()'s first argument is an expression that can evaluate to true or false. Its second argument is the Name of the application to execute if the expression is true. If you need to pass an argument to the application you want ExecIf() to execute then that argument is ExecIf()'s third argument.

I was trying to call Playback as I normally would, like so -> Playback(${filename})
What I needed to do is call it like this -> Playback|${filename}

Clear as mud.