[asterisk-users] Conditional include=> ?

Steve Edwards asterisk.org at sedwards.com
Wed Apr 23 09:44:24 CDT 2008


On Wed, 23 Apr 2008, Steve Davies wrote:

> Wow! That took some finding, as it is little more than a footnote
> (page 115-116 of "Asterisk: The Future of Telephony") but is a
> fantastic feature...
>
> and always in that order? Is this feature well used and well tested???

If you are referring to templates, I have been making heavy use of them 
for years.

I just checked one of my production dialplans -- EVERY context used 
templates except [general] and [globals].

Here's a snippet:

 	; templates
 	[digit-timeout](!)
 	        exten = t,1,                    goto(${CONTEXT},s,1)
 	[h](!)
 	        exten = h,1,                    goto(finish-call,h,1)
 	[i](!)
 	        exten = i,1,                    goto(${CONTEXT},s,1)
 	[max-timeout](!)
 	        exten = T,1,                    goto(max-time,s,1)
 	[pound-hangup](!)
 	        exten = #,1,                    hangup()
 	[pound-main](!)
 	        exten = #,1,                    goto(main-menu,s,1)
 	[s](!)
 	        exten = s,1,                    verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})
 	[x](!)
 	        exten = _x.,1,                  verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})

 	; the main menu
 	[main-menu](digit-timeout,h,i,max-timeout,pound-main,s)

The templates define the common "1 priority" steps that get included 
everywhere. The "real" templates always use the "n priority."

The "order of processing" is as you would expect and is the same between 
1.2 and 1.4. Just be careful of using "uninitialized n" priorities. For 
example:

 	[foo]
 	        exten = x,100,                  this is foo
 	[t2](!)
 	        exten = x,n,                    this is t2
 	[t1](!)
 	        exten = x,n,                    this is t1
 	[t3](t1,t2)
 	        exten = x,1,                    this is t3
 	        exten = x,n,                    this is also t3

results in:

 	dt*CLI> show dialplan t3
 	[ Context 't3' created by 'pbx_config' ]
 	  'x' =>            1. this is t3()                               [pbx_config]
 	                    2. this is also t3()                          [pbx_config]
 	                    101. this is t1()                             [pbx_config]
 	                    102. this is t2()                             [pbx_config]

The "n" priority in [t2] is based on the last seen priority -- the 
priority in the unrelated context [foo].

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list