[Asterisk-Dev] SubString Deprecated

Rick.Bates at kaz-group.com Rick.Bates at kaz-group.com
Thu May 6 22:52:51 MST 2004


Hi I was wondering if anyone else has had this problem?

I have noticed that SubString has been deprecated in favour of
${variable:a:b}. Unfortunately ${variable:a:b} does not appear to replace
the SubString function completely!

See lines 9, 10 & 11, I need to strip a set number of characters from the
RHS of the string, and this does not work
for ${variable:a:b} as it does for SubString!

See below:

Part of extension.conf:
exten=>_975,1,Wait(1)
exten=>_975,2,SetVar(VALUE=2564286161)
exten=>_975,3,SubString,TEST=${VALUE}|0|3
exten=>_975,4,SetVar(TEST=${TEST})
exten=>_975,5,SetVar(TEST=${VALUE:0:3})
exten=>_975,6,SubString,TEST=${VALUE}|-7|7
exten=>_975,7,SetVar(TEST=${TEST})
exten=>_975,8,SetVar(TEST=${VALUE:-7:7})
exten=>_975,9,SubString,TEST=${VALUE}|0|-4
exten=>_975,10,SetVar(TEST=${TEST})
exten=>_975,11,SetVar(TEST=${VALUE:0:-4})
exten=>_975,12,Hangup()

Part of console output:
1-- Executing Wait("IAX2[k000048 at 172.21.103.48:4569]/3", "1") in new stack
2-- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3",
"VALUE=2564286161") in new stack
3-- Executing SubString("IAX2[k000048 at 172.21.103.48:4569]/3",
"TEST=2564286161|0|3") in new stack
May  7 14:43:03 WARNING[-2057884752]: app_substring.c:65 substring_exec:
The use of Substring
application is deprecated. Please use ${variable:a:b} instead
4-- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3", "TEST=256") in
new stack
5-- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3", "TEST=256") in
new stack
6-- Executing SubString("IAX2[k000048 at 172.21.103.48:4569]/3",
"TEST=2564286161|-7|7") in new stack
May  7 14:43:03 WARNING[-2057884752]: app_substring.c:65 substring_exec:
The use of Substring
application is deprecated. Please use ${variable:a:b} instead
7-- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3", "TEST=4286161")
in new stack
8-- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3", "TEST=4286161")
in new stack
9-- Executing SubString("IAX2[k000048 at 172.21.103.48:4569]/3",
"TEST=2564286161|0|-4") in new stack
May  7 14:43:03 WARNING[-2057884752]: app_substring.c:65 substring_exec:
The use of Substring
application is deprecated. Please use ${variable:a:b} instead
10- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3", "TEST=256428")
in new stack
11- Executing SetVar("IAX2[k000048 at 172.21.103.48:4569]/3",
"TEST=2564286161") in new stack
12- Executing Hangup("IAX2[k000048 at 172.21.103.48:4569]/3", "") in new stack

This (above) is a simplified contrived example, I am trying to split apart
the ${CHANNEL} variable, for instance Zap/32-1 to just get the zap channel
part, ie 32, to which I then assign a caller ID for each channel in that
span.  I am doing this as the caller ID's assigned in the zapata.conf come
through to the call plan as blank, even though they are assigned explicitly
for each channel!

I have tried to use the reg ex pattern matching, but I cannot get it to
work either!

Regards Rick Bates





More information about the asterisk-dev mailing list