Hi All, I'm trying to figure out why in the below code, the PSTN_NUM variable is always amended exten => s,n,NoOp(${PSTN_NUM}) exten => s,n,ExecIf( $[ "${PSTN_NUM:0:1}" != "0" ] & $[ ${LEN(${PSTN_NUM})} = 10 ]|Set|PSTN_NUM=001${PSTN_NUM}) exten => s,n,NoOp(${PSTN_NUM}) -- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d0f518", "0123456789") in new stack -- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d0f518", " 0 & 1|Set|PSTN_NUM=0010123456789") in new stack -- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d0f518", "0010123456789") in new stack It should evaluate PSTN_NUM and add a 001 only if: PSTN_NUM is 10 digits long and doesn't start with a 0. However, from the debug it's being changed, even though the first test operator logically is 0. If seems as though the "&" isnt being applied. Any ideas? Thanks Adrian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20080525/483e21db/attachment.htm
Adrian Marsh schrieb:> Hi All, > > I'm trying to figure out why in the below code, the PSTN_NUM variable is > always amended > > exten => s,n,NoOp(${PSTN_NUM}) > exten => s,n,ExecIf( $[ "${PSTN_NUM:0:1}" != "0" ] & $[ > ${LEN(${PSTN_NUM})} = 10 ]|Set|PSTN_NUM=001${PSTN_NUM}) > exten => s,n,NoOp(${PSTN_NUM}) > > -- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d0f518", > "0123456789") in new stack > -- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d0f518", " 0 & > 1|Set|PSTN_NUM=0010123456789") in new stack > -- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d0f518", > "0010123456789") in new stack > > It should evaluate PSTN_NUM and add a 001 only if: PSTN_NUM is 10 digits > long and doesn't start with a 0. > > However, from the debug it's being changed, even though the first test > operator logically is 0. If seems as though the "&" isnt being applied. > > Any ideas? > > Thanks > > Adrianhello, you should try this: exten => s,n,ExecIf($[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[ ${LEN(${PSTN_NUM})} = 10 ]]|Set|PSTN_NUM=001${PSTN_NUM}) cause the AND Operator is another thing to work, so the result at your way look like this ExecIf(1&1 | ...) and with my way it looks like this ExecIf($[1&1]|...) which is the right syntax for it. best regards steve smith
Hi Steve, I can see what yours does, but I still get the same end result (even though theres only a single "0" result now) : exten => s,n,ExecIf( $[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[ ${LEN(${PSTN_NUM})} = 10 ] ] |Set|PSTN_NUM=001${PSTN_NUM}) -- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d9a9a0", "0123456789") in new stack -- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d9a9a0", " 0 |Set|PSTN_NUM=0010123456789") in new stack -- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d9a9a0", "0010123456789") in new stack --------------------------------- hello, you should try this: exten => s,n,ExecIf($[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[ ${LEN(${PSTN_NUM})} = 10 ]]|Set|PSTN_NUM=001${PSTN_NUM}) cause the AND Operator is another thing to work, so the result at your way look like this ExecIf(1&1 | ...) and with my way it looks like this ExecIf($[1&1]|...) which is the right syntax for it. best regards steve smith