Name

GosubIf() — Conditionally branches to a new location, saving the return address

Synopsis

GosubIf(condition?labeliftrue:labeliffalse)

Based upon the evaluation of condition, Gosub will branch execution either to labeliftrue() or labeliffalse. You may return to this same place in the dialplan by later calling Return.

Tip

The word label is often used to denote that you may specify a priority; an extension and a priority; or a context, an extension and a priority. We use the word label to avoid having to spell out all of the possible options each time.

; Specify a default outgoing Caller*ID if one is not set by a specific channel.
exten => _NXXXXXX,1,GosubIf($["${CALLERID(num)}" = ""]?setcallerid,1)
exten => _NXXXXXX,n,Dial(Zap/g1/${EXTEN})
exten => _1NXXNXXXXXX,1,GosubIf($["${CALLERID(num)}" = ""]?setcallerid,1)
exten => _1NXXNXXXXXX,n,Dial(Zap/g1/${EXTEN})
exten => setcallerid,1,Set(CALLERID(num)=6152345678)
exten => setcallerid,n,Return

See Also

Gosub(), Return(), MacroIf(), IF, GotoIf(),