Hi, I'm using asterisk 1.6.1 and AEL2. I'm trying to find the best way to write my own custom functions ? At the moment, I'm using this pattern (extensions.ael) : context foo { 123 => { &myfunc(123456); NoOp(${GOSUB_RETVAL}); }; macro myfunc (arg) { Return (${arg}); } 1. First, I keep getting warnings like Warning: file /etc/asterisk/extensions.ael, line 446-446: application call to Return affects flow of control, and needs to be re-written using AEL if, while, goto, etc. keywords instead! and I would like to get rid of them. 2. Secondly, I would like not to use GOSUB_RETVAL and call a custom function just like I'm calling other functions with statements like : 123 => { NoOp(TOLOWER(fOo BaR)); NoOp(myfunc(123456)); }; What would you advise me to do ? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090511/c61ce3d9/attachment.htm
2009/5/11 Olivier <oza-4h07 at myamail.com>> > 2. Secondly, I would like not to use GOSUB_RETVAL and call a custom > function just like I'm calling other functions with statements like : > 123 => { > NoOp(TOLOWER(fOo BaR)); > > Here, I meantNoOp(read this ${TOLOWER(fOo BaR)}); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090511/f35231e5/attachment.htm
Watkins, Bradley
2009-May-11 11:45 UTC
[asterisk-users] How to write custom functions in AEL2 ,
________________________________ From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Olivier Sent: Monday, May 11, 2009 3:30 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] How to write custom functions in AEL2 , Hi, I'm using asterisk 1.6.1 and AEL2. I'm trying to find the best way to write my own custom functions ? At the moment, I'm using this pattern (extensions.ael) : context foo { 123 => { &myfunc(123456); NoOp(${GOSUB_RETVAL}); }; macro myfunc (arg) { Return (${arg}); } 1. First, I keep getting warnings like Warning: file /etc/asterisk/extensions.ael, line 446-446: application call to Return affects flow of control, and needs to be re-written using AEL if, while, goto, etc. keywords instead! and I would like to get rid of them. Unfortunately, AEL does not support using return with a value at the moment. There is a patch on Reviewboard that does this, as well as *simple* direct assignment from an AEL macro return: http://reviewboard.digium.com/r/114/ 2. Secondly, I would like not to use GOSUB_RETVAL and call a custom function just like I'm calling other functions with statements like : 123 => { NoOp(TOLOWER(fOo BaR)); NoOp(myfunc(123456)); }; What would you advise me to do ? That requires rather a lot more work than the above patch, but if you use the direct assignment at least you needn't worry about GOSUB_RETVAL. Regards, - Brad
Steve Murphy
2009-May-11 14:55 UTC
[asterisk-users] How to write custom functions in AEL2 ,
On Mon, May 11, 2009 at 1:30 AM, Olivier <oza-4h07 at myamail.com> wrote:> Hi, > > I'm using asterisk 1.6.1 and AEL2. > I'm trying to find the best way to write my own custom functions ? > > > At the moment, I'm using this pattern (extensions.ael) : > > context foo { > 123 => { > &myfunc(123456); > NoOp(${GOSUB_RETVAL}); > }; > > macro myfunc (arg) { > Return (${arg}); > } > > 1. First, I keep getting warnings like > Warning: file /etc/asterisk/extensions.ael, line 446-446: application call > to Return affects flow of control, and needs to be re-written using AEL if, > while, goto, etc. keywords instead! > and I would like to get rid of them. >This is easily done. Return() is calling the Return application; 'return', however, is the keyword the AEL uses. Note the lack of a capital R at the beginning of the word "return". AEL is case sensitive and "Return" is not equal to "return". Also note that, as a previous reply mentions, that return takes no args, that there is a patch available to upgrade to do that. You don't need the patch to do what the patch does, tho. But, not having refreshed my memory on the particulars, I will say no more!> > 2. Secondly, I would like not to use GOSUB_RETVAL and call a custom > function just like I'm calling other functions with statements like : > 123 => { > NoOp(TOLOWER(fOo BaR)); > NoOp(myfunc(123456)); > }; > >Again, check your version of Asterisk against whether AEL uses Gosub() to implement macros. The AEL2 wiki page on voip-info.org ( http://voip-info.org/wiki/view/Asterisk+AEL2 ) can also be quite helpful at times!> What would you advise me to do ? > > Regards > > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- Steve Murphy ParseTree Corp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090511/3756f054/attachment.htm