I have a large dial plan here with over 3000 lines, and several dozen macros. As it grew, it became apparent that there was some problems. 1. When you pass arguments to a macro in the form of $ARG1, $ARG2 etc, if that macro calls another macro, and passes arguments like this as well, you lose the original values. 2. When the macro's 'return' some value, it has to set a channel variable. If your not careful, this quickly becomes a mess. Some standard mechanism is needed. In fact, the over all problem is that all channel variables are global within that channel. Macro's don't have local variables and it makes programming large dial plans problematic. Even things like loop counters can get trashed when your inside of a loop, and you jump somewhere else and modify that loop variable, and jump back. Anyone got any tips on how to manage this? It would be awesome if AEL2 could address this somehow... Doug.
Doug Garstang wrote:> I have a large dial plan here with over 3000 lines, and several dozen > macros. As it grew, it became apparent that there was some problems. > > 1. When you pass arguments to a macro in the form of $ARG1, $ARG2 etc, > if that macro calls another macro, and passes arguments like this as > well, you lose the original values. > > 2. When the macro's 'return' some value, it has to set a channel > variable. If your not careful, this quickly becomes a mess. Some > standard mechanism is needed. > > In fact, the over all problem is that all channel variables are global > within that channel. Macro's don't have local variables and it makes > programming large dial plans problematic. Even things like loop counters > can get trashed when your inside of a loop, and you jump somewhere else > and modify that loop variable, and jump back. > > Anyone got any tips on how to manage this? It would be awesome if AEL2 > could address this somehow...You're so right! I thought about having just a catchall _. extension in the dialplan and doing everything else in a "real" language via AGI - PHP, Perl, ... whichever you like. It would make the programming part much easier as the scope of variables is just as you expect it to be. Regards, Philipp -- amooma GmbH - Bachstr. 126 - 56566 Neuwied - http://www.amooma.de Let's use IT to solve problems and not to create new ones. Asterisk? -> http://www.das-asterisk-buch.de Gesch?ftsf?hrer: Stefan Wintermeyer Handelsregister: Neuwied B 14998
Doug Garstang wrote:> I have a large dial plan here with over 3000 lines, and several dozen > macros. As it grew, it became apparent that there was some problems. > > 1. When you pass arguments to a macro in the form of $ARG1, $ARG2 etc, > if that macro calls another macro, and passes arguments like this as > well, you lose the original values. > > 2. When the macro's 'return' some value, it has to set a channel > variable. If your not careful, this quickly becomes a mess. Some > standard mechanism is needed. > > In fact, the over all problem is that all channel variables are global > within that channel. Macro's don't have local variables and it makes > programming large dial plans problematic. Even things like loop counters > can get trashed when your inside of a loop, and you jump somewhere else > and modify that loop variable, and jump back. > > Anyone got any tips on how to manage this? It would be awesome if AEL2 > could address this somehow...A possible "solution" would be to prefix all variables used within a macro with the name of the macro but you really feel it's a workaround. macro do_something( do_something_foo, do_something_bar ) { Set(do_something_i=0); //... } But how nice is ${do_something_i} ? Regards, Philipp -- amooma GmbH - Bachstr. 126 - 56566 Neuwied - http://www.amooma.de Let's use IT to solve problems and not to create new ones. Asterisk? -> http://www.das-asterisk-buch.de Gesch?ftsf?hrer: Stefan Wintermeyer Handelsregister: Neuwied B 14998