<DIV>I was setting up an extensions.conf the other day when I realized some things I wish were possible and just tossing it up for input.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>1)</DIV>
<DIV>&nbsp;</DIV>
<DIV>If you used a certian variable in a context it would be nice if you could</DIV>
<DIV>change the value of that variable right before you do an include so you </DIV>
<DIV>could make templates of sorts that could be controlled by the include command.</DIV>
<DIV>&nbsp;</DIV>
<DIV>For example</DIV>
<DIV>&nbsp;</DIV>
<DIV>[globals]</DIV>
<DIV>OUT1=Zap/1</DIV>
<DIV>OUT2=Zap/2</DIV>
<DIV>&nbsp;</DIV>
<DIV>[generic]</DIV>
<DIV>exten =&gt; _9.,1,Dial(${OUT}/${EXTEN:1})</DIV>
<DIV>&nbsp;</DIV>
<DIV>[ex1]</DIV>
<DIV>include =&gt; generic, OUT=${OUT1}</DIV>
<DIV>&nbsp;</DIV>
<DIV>[ex2] </DIV>
<DIV>include =&gt; generic, OUT=${OUT2}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I accomplished this using my app_perl module but doing at natively doesnt seem too complicated.</DIV>
<DIV>&nbsp;</DIV>
<DIV>[generic]</DIV>
<DIV>
<DIV>exten =&gt; _9.,1,Perl,dial_by_context:${CONTEXT}</DIV></DIV>
<DIV>
<DIV>exten =&gt; _9.,2,Dial(${USETRUNK}/${EXTEN:1})</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>[ex1]</DIV>
<DIV>include =&gt; generic</DIV>
<DIV>&nbsp;</DIV>
<DIV>[ex2] </DIV>
<DIV>include =&gt; generic</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV># in my asterisk_init.pm </DIV>
<DIV>&nbsp;</DIV>
<DIV>sub dial_by_context(@) {<BR>&nbsp; my ($context) = @_;</DIV>
<DIV>&nbsp; my %trunks = (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ex1 =&gt; "Zap/1",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ex2 =&gt; "Zap/2",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default =&gt; "Zap/1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</DIV>
<DIV>&nbsp; $trunks{$context} ||= $trunks{default};</DIV>
<DIV>&nbsp; return ("setvar:USETRUNK:$trunks{$context}");</DIV>
<DIV>}<BR></DIV>
<DIV>then when you are in context ex1 the ${USETRUNK} is Zap/1</DIV>
<DIV>and in ex2 it's Zap/2 but you only need 1 generic context.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>2)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Another possibility could be to implement associative arrays as global variables.</DIV>
<DIV>&nbsp;</DIV>
<DIV>[globals]</DIV>
<DIV>&nbsp;</DIV>
<DIV>[global_hashes]</DIV>
<DIV>TRUNKS = (ex1 =&gt; "Zap/1", ex2 =&gt; "Zap/2") </DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>[generic]</DIV>
<DIV>exten =&gt; _9.,1,Dial(${TRUNKS}-&gt;[${CONTEXT}]/${EXTEN:1})</DIV>
<DIV>&nbsp;</DIV>
<DIV>[ex1]</DIV>
<DIV>include =&gt; generic, OUT=${OUT1}</DIV>
<DIV>&nbsp;</DIV>
<DIV>[ex2] </DIV>
<DIV>include =&gt; generic, OUT=${OUT2}</DIV>
<DIV>&nbsp;</DIV>
<DIV>3)</DIV>
<DIV>&nbsp;</DIV></DIV>
<DIV>Finally a regex engine would be nice to perform tranlation on variables</DIV>
<DIV>I also do this with app_perl but it could be native as well</DIV>
<DIV>&nbsp;</DIV>
<DIV>Say you want to be able to dial an IP address on an analog phone by</DIV>
<DIV>using the * as a period and pattern match it and feed it to H323</DIV>
<DIV>&nbsp;</DIV>
<DIV>exten =&gt; _9*.*.*.*.,1,Perl,star_to_ip:${EXTEN:2}<BR>exten =&gt; _9*.*.*.*.,2,Ringing<BR>exten =&gt; _9*.*.*.*.,3,Dial(H323/${CALLIP})<BR>exten =&gt; _9*.*.*.*.,4,Congestion<BR></DIV>
<DIV>sub star_to_ip(@) {<BR>&nbsp; my $num = shift;<BR>&nbsp; $num =~ s/\*/\./g;<BR>&nbsp; return "setvar:CALLIP:$num";<BR>}<BR></DIV>
<DIV>perhaps just magic special var called ${SUBSTITUTE}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>exten =&gt; _9*.*.*.*.,1,Substitute,${EXTEN:2},*,.<BR>exten =&gt; _9*.*.*.*.,2,Ringing<BR>exten =&gt; _9*.*.*.*.,3,Dial(H323/${SUBSTITUTED})<BR>exten =&gt; _9*.*.*.*.,4,Congestion<BR></DIV>
<DIV>i'm sure app_substitute could be its own module I'm just offering input </DIV>
<DIV>That's kinda why I wanted to make an app_perl so I could just make stuff </DIV>
<DIV>on the fly w/o doing any C but I think i need to go work on it a little more before </DIV>
<DIV>it's pubicly accepted.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software