Summary:ASTERISK-05720: "CUT" function does not seem to function as expected, or at all
Reporter:John Todd (jtodd)Labels:
Date Opened:2005-11-27 14:47:30.000-0600Date Closed:2011-06-07 14:10:02
Versions:Frequency of
Description:I seem to be either doing this incorrectly, or it is not working as intended:

exten => 2228,n,Set(shiz=${CUT(1234abcd,a,2)})
exten => 2228,n,NoOp(shiz=${shiz})


   -- Executing Set("SIP/tello.com-08178718", "shiz=") in new stack
   -- Executing NoOp("SIP/tello.com-08178718", "shiz=") in new stack  

Expected results:


I've tried the following, with the same results:
exten => 2228,n,Set(shiz=${CUT(1234abcd,"a",2)})

exten => 2228,n,Set(foo=1234abcd)
exten => 2228,n,Set(shiz=${CUT(${foo},a,2)})

This originally extended from my attempts to use the "@" sign as a field separator in SIP manipulations, but boiled down to either my continued misunderstanding of the CUT function, or a bug.  I also tried using the (older) app_cut, with similar failure results.  I have also tried different field delimiters, with no valid results (1,3)
Comments:By: Tilghman Lesher (tilghman) 2005-11-27 22:31:29.000-0600

As noted in the help and on the Wiki, the CUT function takes a variable NAME as an argument, not a STRING.  By doing variable interpolation in the dialplan, you are handing the function a string, not a variable name.

Your example would work if there was such a variable as ${1234abcd}.

By: Tilghman Lesher (tilghman) 2005-11-27 22:33:11.000-0600

Note the typical example is the use of the CHANNEL variable, i.e.: