Hi,<div><br></div><div>I try to avoid any warnings, as they can turn into errors later.</div><div><br></div><div>I remember having problems with GoSub long time ago, don't remember what it was, but I moved to macros after that.</div>
<div><br></div><div>For what you are trying to achieve, I use macros. Just jump to a macro, evaluate what you need to, save the results in variables, and use these variables in the calling context to proceed further. For example, in my context for outbound calls, called [outbound], I jump to macro [user-account-info], get account info, come back to [outbound], then jump to [blacklist], check the caller ID against a blacklist, come back to [outbound], jump to two other macros, and finally I have all the info I need to proceed with a call, stored in various variables. Based on these variables I trigger the Dial command, or do something else as needed.</div>
<div><br></div><div>In your case, you can make it even simpler, e.g. like this:</div><div><br></div><div><div>context outboundSimple {</div><div> _9X. => {</div><div> // prepare callerid, secret, ...</div>
<div> /// ...</div><div><br></div><div> // start call routing</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if("${EXTEN:1:3}"="06") {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&pstnInterface2(${EXTEN:1});</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>else {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>&pstnInterface1(${EXTEN:1});</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>};</div><div> // back, handle return status</div><div> };</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>h => {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&dialstatus(${DIALSTATUS},${EXTEN:1});</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>};</div><div><br></div><div>}</div><div>
<br></div><div><br></div><div>macro pstnInterface1(number) {</div><div><br></div><div> // setup the interface callerid/secret status</div><div><br></div><div> ChanIsAvail(DAHDI/g1);</div><div>
if( ! ${ISNULL(${AVAILORIGCHAN})} ) {</div><div> Dial(DAHDI/g1/${number},,${dialopts});</div><div> };</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>catch h {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&dialstatus(${DIALSTATUS},${number});<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>};</div>
<div><br></div><div>}</div><div><br></div><div>macro pstnInterface2(number) {</div><div><br></div><div> // setup the interface callerid/secret status</div><div><br></div><div> ChanIsAvail(SIP/....);</div>
<div> if( ! ${ISNULL(${AVAILORIGCHAN})} ) {</div><div> Dial(SIP/.../${number},,${dialopts});</div><div> };</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>catch h {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>&dialstatus(${DIALSTATUS},${number});<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>};</div>
<div>}</div></div><div><br><div class="gmail_quote">On Fri, Jul 23, 2010 at 9:50 AM, Benoit <span dir="ltr"><<a href="mailto:maverick@maverick.eu.org">maverick@maverick.eu.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi,<br>
<br>
For some reason (outbound call tracking) I've got a few different<br>
outbound call process (using a macro for queuemetrics logging, or direct<br>
call)<br>
i wanted to factorise the routing process so i came up with something<br>
like the following. All in one it's working like expected, however<br>
every "ael reload" command trigger a lot of warning like that<br>
<br>
"application call to Gosub affects flow of control, and needs to be<br>
re-written using AEL if, while, goto, etc. keywords instead!"<br>
<br>
But i fail to see how i could do it another way, any idea/suggestion ?<br>
<br>
<br>
Extraction of the outbound processing structure:<br>
<br>
context outboundSimple {<br>
_9X. => {<br>
// prepare callerid, secret, ...<br>
/// ...<br>
<br>
// start call routing<br>
Gosub(pstnRouting,${EXTEN:1},1);<br>
// back, handle return status<br>
&dialstatus(${DIALSTATUS},${EXTEN:1});<br>
}<br>
}<br>
<br>
context outboundQueue1 {<br>
_9X. => {<br>
// prepare callerid, secret, ...<br>
/// ...<br>
<br>
&qmoutqdial(${EXTEN:1},DAHDI/g1/${EXTEN:1},queue-out,Agent/${AgentNum});<br>
}<br>
}<br>
<br>
context outboundQueue2 {<br>
....<br>
}<br>
<br>
// outbound call logging for queuemetrics:<br>
macro qmoutqdial( clid, dialstring, queue, agent )<br>
{<br>
start_dial_time = ${EPOCH};<br>
QueueLog(${queue},${UNIQUEID},${agent},CALLOUTBOUND,-|${clid});<br>
<br>
<br>
Set(dialopts=gWKU(queuelog_connect_event^${queue}^${UNIQUEID}^${agent}^${start_dial_time}));<br>
Gosub(pstnRouting,${clid},1);<br>
<br>
end_dial_time = ${EPOCH};<br>
verb = COMPLETECALLER;<br>
&queuelog_hangup_event(${queue},${UNIQUEID},${agent},${start_dial_time});<br>
return;<br>
}<br>
<br>
<br>
// central call routing rules<br>
context pstnRouting {<br>
<br>
_06XXXXXXXX => { Gosub(pstnInterface2,${EXTEN},1); Return; }<br>
....<br>
<br>
// left over<br>
_X. => { Gosub(pstnInterface1,${EXTEN},1); Return; }<br>
}<br>
<br>
context pstnInterface1 {<br>
_X. => {<br>
// setup the interface callerid/secret status<br>
<br>
ChanIsAvail(DAHDI/g1);<br>
if( ! ${ISNULL(${AVAILORIGCHAN})} ) {<br>
Dial(DAHDI/g1/${ext},,${dialopts});<br>
}<br>
Return;<br>
}<br>
}<br>
<br>
context pstnInterface2 {<br>
_X. => {<br>
// setup the interface callerid/secret status<br>
<br>
ChanIsAvail(SIP/....);<br>
if( ! ${ISNULL(${AVAILORIGCHAN})} ) {<br>
Dial(SIP/.../${ext},,${dialopts});<br>
}<br>
Return;<br>
}<br>
}<br>
<br>
<br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
<a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Zeeshan A Zakaria<br>
</div>