Christopher Arnold
2003-Jun-11 08:43 UTC
[Asterisk-Users] How do i make best use of Macro?
Hi, im trying to setup a chat system. And i belive the best way is using an macro. But a couple of questions regarding using macros pops up. a) Is there state building up if my macro calls itself recusivly? Pseudo example: [macro-chat] to_many? Macro(chat, next_room) increase # of users in chat meeteme(room) exit from meetme: decrease # of users in chat then Macro(chat, next_room) exten => h,1, decrease # of users in chat <end example> In this example i call the macro again and again until hangup. Is this a good way to implement my chat functionality? Or should i try another path? b) How do i return from a macro? Do i just fall out by not having any more valid extensions in the macro? Vill execution then continue at the next priority? Or should i use a Goto(newcontext,s,1)? /Chris
On Wednesday 11 June 2003 10:43 am, Christopher Arnold wrote:> Hi, > > im trying to setup a chat system. And i belive the best way is > using an macro. But a couple of questions regarding using macros > pops up. > > a) Is there state building up if my macro calls itself recusivly?A macro is NOT a function. It simply is a shortcut to doing a longer series of commands. A macro cannot itself be recursive.> b) How do i return from a macro?One does not return from a macro. Indeed, once the macro is expanded, it is no longer part of the process.> Or should i use a Goto(newcontext,s,1)?I think you're confused as to what a macro can and cannot do. Until you understand that distinction, you're going to have trouble understanding how a macro works within the system. In any case, I'd recommend that you forget about using macros and instead use AGI. -Tilghman
Steven Critchfield
2003-Jun-11 13:12 UTC
[Asterisk-Users] How do i make best use of Macro?
On Wed, 2003-06-11 at 14:43, Tilghman Lesher wrote:> On Wednesday 11 June 2003 02:09 pm, Steven Critchfield wrote: > > Okay, while reading over this thread it occured to me one more > > feature that should be real simple to add to app_meetme.c that > > would solve quite a bit of what is trying to be done here. The > > feature that needs to be added is a function to pass in a variable > > and let meetme populate it with the current number of users. > > Possibly have it be a second argument to the current MeetMeCount > > that would populate the variable and skip the ast_say_number > > function. This would allow it to be backwards compatible, while > > moving forward. > > > > How it would benefit the current question is that you could > > basically script up a fall through set of priorities that made it > > work > > > > exten=> x,1,MeetMeCount(1234,num) > > Applications can only take a single argument. I would propose > using something like (e1234) - e for export variable; then export > the value to a common variable like ${MEETMECOUNT}.True and false. You get passed data, and what you do with data is up to you. I could split on some non important character and do what I want with the string. So while you are correct, I can do anything I want with my string. -- Steven Critchfield <critch@basesys.com>
There is already a "MeetmeCount" application if that's helpful. mark On Wed, 11 Jun 2003, Christopher Arnold wrote:> > Hi, > > im trying to setup a chat system. And i belive the best way is using an > macro. But a couple of questions regarding using macros pops up. > > a) Is there state building up if my macro calls itself recusivly? > > Pseudo example: > [macro-chat] > to_many? Macro(chat, next_room) > increase # of users in chat > > meeteme(room) > > exit from meetme: decrease # of users in chat then Macro(chat, next_room) > > exten => h,1, decrease # of users in chat > > <end example> > > In this example i call the macro again and again until hangup. > > Is this a good way to implement my chat functionality? > Or should i try another path? > > > b) How do i return from a macro? > Do i just fall out by not having any more valid extensions in the macro? > Vill execution then continue at the next priority? > > Or should i use a Goto(newcontext,s,1)? > > > /Chris > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users@lists.digium.com > http://lists.digium.com/mailman/listinfo/asterisk-users >