Everything is working fine but when reload ael I get warnings like this:
Warning: file xxx line 8-8: application call to Gosub affects flow of control, and needs to be re-written using AEL if, while, goto, etc. keywords instead!
I have read about this and it seems to be a known Bug since asterisk 1.6, that appears as resolved. Any idea why I still have these warnings in asterisk13?
Macros are very similar in function to the Gosub application which deprecates Macro. This information is here for historical purposes and you should really use Gosub wherever you would have previously used Macro.
The warning is still there, see the source code of the asterisk 21 release:
You should use the macro AEL construct for your mySubroutine. AEL generates a dialplan context from your mySubroutine AEL macro. Then you can call this AEL macro by &mySubroutine(...) in your myContext context. AEL parser generates a Gosub call to that context, so the deprecated Macro() dialplan application is not used:
macro mySubroutine(theParam) { // <-------------- it's an ael macro
/* .... some logic here to determine asError and gotoLabel variables ... . */
if("${asError}"!=""){
Noop("${asError} ${SYSTEMNAME}");
Return("");
}
if ( "${gotoLabel}"!=""){
Return(${gotoLabel});
}
else{
Noop("No label for ${CHANNEL(name)} ${SYSTEMNAME}");
}
Return("");
};
context myContext {
s => {
&mySubroutine(someParamHere); // <------ call ael macro
if ( "${GOSUB_RETVAL}"!=""){
goto ${GOSUB_RETVAL};
}
}
}