Philipp Kempgen wrote:
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

Philipp, that's what I've been doing. For readability sake, I normally have macro's with long descriptive names, like macro-VMRetrCheckGeneral for example. That;s ok until you start suffixing variable names to the end. You might end up with:

VMRetrCheckGeneral_new
VMRetrCheckGeneral_old
VMRetrCheckGeneral_i

and so on. I guess it's better than nothing....

I feel that the lack of local macro variables is a big problem for the dial plan. Until it's fixed it will hamper the development of large dial plans.


_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to