Asterisk cmd GosubIf

GosubIf

Conditionally jump to a particular priority, extension, or context, saving the return address.

Synopsis

  GosubIf(condition?[label1][:label2])

Asterisk 1.6 and up (?):
  GosubIf(condition?[labeliftrue[(arg1[,...][,argN])]][:labeliffalse[(arg1[,...][,argN])]])


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)

; New/extended syntax:
GosubIf($["${CALLERID(num)}" =~ "1234567$"]?dial-some-special,${EXTEN},1(arg1,arg2):dial-as-usually,${EXTEN},1(arg1,arg2))

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

GosubIf

Conditionally jump to a particular priority, extension, or context, saving the return address.

Synopsis

  GosubIf(condition?[label1][:label2])

Asterisk 1.6 and up (?):
  GosubIf(condition?[labeliftrue[(arg1[,...][,argN])]][:labeliffalse[(arg1[,...][,argN])]])


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)

; New/extended syntax:
GosubIf($["${CALLERID(num)}" =~ "1234567$"]?dial-some-special,${EXTEN},1(arg1,arg2):dial-as-usually,${EXTEN},1(arg1,arg2))

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
Created by: JustRumours, Last modification: Mon 25 of Jun, 2012 (11:27 UTC) by brownian
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+