[Asterisk-Dev] How Do I ... time for a index/strpos function ??
Steven
critch at basesys.com
Tue May 24 07:46:30 MST 2005
On Tue, 2005-05-24 at 16:11 +0200, Gregory Hinton Nietsky wrote:
>
> i want have a simple macro to set the DB with information on how to handle
> DDI/MSN i however have numbers of various lengths my current DP looks like
> this ...
>
> exten => _*94*XXXX*XX.,1,Macro(setddi,${EXTEN:4:4},${EXTEN:9})
> exten => _*94*XXXXX*XX.,1,Macro(setddi,${EXTEN:4:5},${EXTEN:10})
> exten => _*94*XXXXXX*XX.,1,Macro(setddi,${EXTEN:4:6},${EXTEN:11})
> exten => _*94*XXXXXXX*XX.,1,Macro(setddi,${EXTEN:4:7},${EXTEN:12})
> exten => _*94*XXXXXXXX*XX.,1,Macro(setddi,${EXTEN:4:8},${EXTEN:13})
> exten => _*94*XXXXXXXXX*XX.,1,Macro(setddi,${EXTEN:4:9},${EXTEN:14})
> exten => _*94*XXXXXXXXXX*XX.,1,Macro(setddi,${EXTEN:4:10},${EXTEN:15})
>
> rather messy what id like to do is
> exten => _*94*X.,1,Macro(setddi,${EXTEN})
>
> and do somthing like this in the macro
> exten => s,n,SET(NUMBER=${STRPOS(*,${ARG1})}
> exten => s,n,SET(DB(DDI/${ARG1:1:${NUMBER}})=${ARG1:${NUMBER}})
Why not do this instead?
[main]
exten => *94*,1,Goto(GetNumber,s,1)
[GetNumber]
exten => s,1,NoOp
exten => _X.*,1,Set(NUMBER=${EXTEN:0:-1})
exten => _X.*,n,Goto(GetDDI,s,1)
[GetDDI]
exten => s,1,NoOp
exten => _XX.,1,Set(DB(DDI/${NUMBER}=${EXTEN})
Not saying a strpos function wouldn't be a welcome change as well.
--
Steven <critch at basesys.com>
More information about the asterisk-dev
mailing list