[VoIP] Zaptel end-of-dialing
Shane Young
voiptandem at shaneyoung.com
Thu Sep 6 14:46:23 CDT 2007
This should work for numbers between 2 and 16 digits long. You don't
need to modify the dial-cnet macro, you just send the correct digits
to it:
[some-context]
exten => _x.,1,Macro(dial-cnet)
exten => _xx#,1,goto(${EXTEN:0:2})
exten => _xxx#,1,goto(${EXTEN:0:3})
exten => _xxxx#,1,goto(${EXTEN:0:4})
exten => _xxxxx#,1,goto(${EXTEN:0:5})
exten => _xxxxxx#,1,goto(${EXTEN:0:6})
exten => _xxxxxxx#,1,goto(${EXTEN:0:7})
exten => _xxxxxxxx#,1,goto(${EXTEN:0:8})
exten => _xxxxxxxxx#,1,goto(${EXTEN:0:9})
exten => _xxxxxxxxxx#,1,goto(${EXTEN:0:10})
exten => _xxxxxxxxxxx#,1,goto(${EXTEN:0:12})
exten => _xxxxxxxxxxxx#,1,goto(${EXTEN:0:13})
exten => _xxxxxxxxxxxxx#,1,goto(${EXTEN:0:14})
exten => _xxxxxxxxxxxxxx#,1,goto(${EXTEN:0:15})
exten => _xxxxxxxxxxxxxxx#,1,goto(${EXTEN:0:16})
There might be a combination that tells the substring function to just
strip the last character, but this should get you what you need.
Quoting Greg Blakely <greg at vyger.net>:
> The problem with this scenario is that I need to know ahead of time how
> many digits will be dialed.
>
> What I need is some way to tell asterisk, "Yup, I'm done. Take however
> many digits I just sent, and then strip the # off the end."
>
>> -----Original Message-----
>> From: voip-bounces at ckts.info [mailto:voip-bounces at ckts.info]
>> On Behalf Of Shane Young
>> Sent: Thursday, September 06, 2007 2:22 PM
>> To: voip at ckts.info
>> Subject: Re: [VoIP] Zaptel end-of-dialing
>>
>> Again, there are several ways to skin a cat (or dialplan)...
>>
>> If you dial 18217301#
>> Your EXTEN variable is set to 18217301#.
>>
>> When it's passed to the macro, the variable name is
>> MACRO_EXTEN You could use ${MACRO_EXTEN:0:11) to skip 0
>> digits and use the next 11 digits, this eliminating the 12th digit (#)
>>
>> The nice thing is you can use the same thing even if you
>> don't dial the #.
>> It will still skip 0 digits and use the next 11.
>>
>>
>> Another way might be to do something like this:
>>
>> [somecontext]
>> exten => _1X.,1,Macro(dial-cnet)
>> exten => _1X.#,1,GoTo(somecontext,${EXTEN:0:11},1)
>>
>> The first one would just fire after the timer and follow the
>> normal path.
>> The second one would loop back and "start over" as if you had
>> dialed the number without the # ad the end, but would not
>> wait for any addtional digits. It would then pick the first entry.
>>
>>
>>
>>
>>
>> the voip-info wiki gives information about the use of
>> substrings within a variable:
>>
>> http://www.voip-info.org/wiki/index.php?page=Asterisk+variables
>>
>> Substrings
>> ${foo:offset:length}
>>
>> returns a substring of the string foo, beginning at offset
>> offset and returning the next length characters.
>>
>> If offset is negative, it is taken leftwards from the right
>> hand end of the string.
>> If length is omitted or is negative, then all the rest of the
>> string beginning at offset is returned.
>>
>> Examples:
>>
>> ${123456789:1} - returns the string 23456789
>> ${123456789:-4} - returns the string 6789
>> ${123456789:0:3} - returns the string 123
>> ${123456789:2:3} - returns the string 345
>> ${123456789:-4:3} - returns the string 678
>>
>> Examples of use:
>>
>> exten => _NXX.,1,SetVar(areacode=${EXTEN:0:3}) - get
>> the first 3
>> digits of ${EXTEN}
>> exten => _516XXXXXXX,1,Dial(${EXTEN:3}) - get
>> all but the
>> first 3 digits of ${EXTEN}
>> exten => 100,1,SetVar(whichVowel=4)
>>
>> exten => 100,2,SetVar(foo=AEIOU:${whichVowel}:1) - sets
>> ${foo} to the single letter 'U'
>>
>>
>>
>>
>> Quoting Greg Blakely <greg at vyger.net>:
>>
>> > Okay. That works, except for figuring out how to send the correct
>> > digits to the dial-cnet macro.
>> >
>> > I am wondering if it wouldn't be easiest to modify the
>> dial-cnet macro
>> > to ignore the # sign. Any ideas on how to do that? Or to send the
>> > macro the correct digits, for that matter?
>> > _______________________________________________
>> > VoIP mailing list
>> > VoIP at ckts.info
>> > http://lists.ckts.info/mailman/listinfo/voip
>> > Project Web Page: http://www.ckts.info/
>> >
>>
>> --Shane
>> +1-821-7311 CNET
>>
>>
>> _______________________________________________
>> VoIP mailing list
>> VoIP at ckts.info
>> http://lists.ckts.info/mailman/listinfo/voip
>> Project Web Page: http://www.ckts.info/
>>
>>
> _______________________________________________
> VoIP mailing list
> VoIP at ckts.info
> http://lists.ckts.info/mailman/listinfo/voip
> Project Web Page: http://www.ckts.info/
>
--Shane
+1-821-7311 CNET
More information about the VoIP
mailing list