On Aug 11, 2004, at 9:45 AM, Christopher L. Wade wrote:
Mike Coakley wrote:Chris,
Actually it is a documented feature of Macro. Macro only executes extension "s" there are no other extensions in the macro context. I ran into this while working through building our dial plan. It was driving me nutz. (But the WIKI rescued me.) What I had to do is use the Macro to setup the call as needed and then Goto a context that had all the extensions I needed.
For a complete example:
I wanted to be able to call an station and if that station didn't answer I wanted to present the user with a menu that they could press #1 to leave a voicemail, #2 to try again, #4 to go to the main menu, #8 to call the group/department the station belongs to, #9 to go to the group/department directory or #0 to go to operator. Here is what I had to do BECAUSE Macro can only execute the "s" extension.
[macro-stationcall]
exten => s,1,SetVar(STATION_EXT=${ARG1})
exten => s,2,SetVar(STATION_MAILBOX=${ARG2})
exten => s,3,SetVar(STATION_GROUP=${ARG3})
exten => s,4,SetVar(STATION_MENU=${ARG4})
exten => s,5,SetVar(STATION_DIRECTORY=${ARG5})
exten => s,6,Goto(stationcall_menu,s,1)
[stationcall_menu]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,DigitTimeout(5)
exten => s,4,ResponseTimeout(5)
exten => s,5,AbsoluteTimeout(30)
exten => s,6,Dial(${STATION_EXT})
exten => s,7,Background(${STATION_MENU})
exten => 1,1,Voicemail(u${STATION_MAILBOX})
exten => 2,1,Goto(s,6)
exten => 4,1,Goto(main_menu,s,1)
exten => 8,1,Macro(groupcall,${STATION_GROU})
exten => 9,1,Directory(${STATION_DIRECTORY})
exten => 0,1,Goto(operator,s,1)
exten => i,1,Playback(invalid)
exten => i,2,Goto(s,7)
exten => t,1,Goto(s,7)
exten => T,1,Hangup
I simplified this example (trust me) but I hope you get the idea. Also realize that SetVar puts a variable in the scope of the current call.
Hope this helps.
Mike
On Aug 10, 2004, at 5:59 PM, Christopher L. Wade wrote:Okay, time for an update.
I posted this as a bug. Very quickly got informed that it is not a bug, but instead, an undocumented 'feature'.
AbsoluteTimeout is treated as an *exception* (ie it looks like a hangup) by most applications, including Macro, which makes most applications exit.
This being said, this is why a 'T' extension in the calling context would run, but not a 'T' extension inside the macro. Once macro exists, the macro context no longer exists, and the 'T' extension inside the macro becomes 'inaccessible'.
Oh well, I guess I'll have to implement my logic without macros. Hopefully variables aren't screwed up by AbsoluteTimeout.
Thanks, Chris
Well, according to the wiki - see the macro-stdexten, 's' is not the only extension that can be used within a macro. The stdexten macro uses Goto and ${DIALSTATUS} to branch to s-${DIALSTATUS} (you can change this to just ${DIALSTATUS} if you want, it still works, but pattern matching that to group unhandled values isn't as clean and recognizable as 's-.' is.
Also, the following example shows you can branch as much as you like inside a macro:
[macro-testM] exten => s,1,Goto(test,1) exten => test,1,NoOp(${CONTEXT},${MACRO_CONTEXT})
This macro, when run, will print the following assuming you start asterisk CLI with verbosity high enough and debug on (I always start it this way).
Executing NoOp("Zap/1-1", "macro-testM|internal") in new stack
So, again, the wiki is "wrong". Well, not quite, the wiki is right in that you *must* have the 's' extension and that this is where your macro execution will *always* start. But, once inside the macro, you can do just about anything you want, except use exceptions.
OK. I'm with you... and you are correct... I do use s-${DIALSTATUS} in macros and it does work (FORGOT about that :-D). I will say two things: (a) no matter what I tried - updating CVS, all sorts of contortions, and then using NoOp to print debugging information - I was not able to get Macro alone working the way I have it working now... the callwould always would loose the call context and things would just get worse from there (b) The WIKI is only as accurate as we make it. So I guess once we (* community) get this nailed down in order to help the community we should update the WIKI. With my WIKI comment said... I now wonder which should be right... should only extension "s" work within a Macro - seems very limiting or should the WIKI be updated to now include other extensions. If the latter is true... what extensions? I assume what extensions are valid in a Macro would truly boil down to what context the Macro stays in while processing and this is what might have changed to make the s-${DIALSTATUS} work. The coders will know and maybe it is time to dig into the code.
Anyone out there with * code experience that can put this question to bed.
Thanks, Chris
_______________________________________________ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Thanks,
Mike
_______________________________________________ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
