Asterisk cmd GosubIf
Created by: JustRumours,Last modification on Tue 13 of Nov, 2007 [19:40 UTC] by jon.webster
GosubIf
Conditionally jump to a particular priority, extension, or context, saving the return address.Synopsis
GosubIf(condition?label1:label2)Description
If condition is true and label1 points to a existing context|extension|priority or extension|priority or priority, then jump to that location, saving the return address. If condition is false, the same applies for label2.
Labels take the form '[context,]extension,]priority', so they can be (a) a priority, (b) an extension and a priority, or (c) a context, an extension and a priority.
Return Codes
Returns 0, or -1 if the given context, extension, or priority is invalid.Example
exten => maincid,1,Set(CALLERID(all)=Some Company <6153824758>)exten => maincid,2,Return
exten => faxcid,1,Set(CALLERID(all)=Some Company <6153847735>)
exten => faxcid,2,Return
; External local
exten => _9NXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9NXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External long distance
exten => _91NXXXXXXXXX,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _91NXXXXXXXXX,n,Dial(${TRUNK}/${EXTEN:1},,T)
; External international
exten => _9011.,1,GosubIf($[${CHANNEL:4:2} = 43]?faxcid,1:maincid,1)
exten => _9011.,n,Dial(${TRUNK}/${EXTEN:1},,T)
See also
- Gosub: Jump to a context/extension/priority (new in v1.2)
- Return: Return from a subroutine (new in v1.2)
- Goto: Jump to a context/extension/priority
- GotoIf: Conditional jump to a context/extension/priority
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Comments