Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

please do not repeat the tags in the title
Source Link
desertnaut
  • 60.8k
  • 32
  • 155
  • 183

Asterisk : Using Cut with multiple delimeter

I have a small problem. I have a variableCTI_VARIABLES with this content:

cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1

Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with the CUT() function. But it only returns the first one, because it accepts a single character as an argument. How can I do it when I want to separate by two characters?

Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

I also tried using the FIELDQTY() function with no luck:

TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)}
TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)}

Asterisk : Using Cut with multiple delimeter

I have a small problem. I have a variableCTI_VARIABLES with this content:

cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1

Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with the CUT() function. But it only returns the first one, because it accepts a single character as an argument. How can I do it when I want to separate by two characters?

Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

I also tried using the FIELDQTY() function with no luck:

TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)}
TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)}

Using Cut with multiple delimeter

I have a small problem. I have a variableCTI_VARIABLES with this content:

cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1

Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with the CUT() function. But it only returns the first one, because it accepts a single character as an argument. How can I do it when I want to separate by two characters?

Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

I also tried using the FIELDQTY() function with no luck:

TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)}
TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)}
deleted 78 characters in body
Source Link
miken32
  • 42.5k
  • 16
  • 127
  • 177

I have a small problem. I have a variables getting from AGI likevariableCTI_VARIABLES with this. CTI_VARIABLES content: "cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1" Each

cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1

Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with CUTthe CUT() function. I think CUTBut it only operatesreturns the first one of them, because it accepts chara single character as an argument. How can I do it when I want to separate by two characters? Here

Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

If there is a different method you suggest, I can use it. Thank you

Ialso tried using the FIELDQTY() function with no luck:

1 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)})

2 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)})

But none of them separated the two characters with CUT.

I have a small problem. I have a variables getting from AGI like this. CTI_VARIABLES: "cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1" Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with CUT. I think CUT only operates one of them because it accepts char. How can I do it when I want to separate by two characters? Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

If there is a different method you suggest, I can use it. Thank you

I tried

1 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)})

2 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)})

But none of them separated the two characters with CUT.

I have a small problem. I have a variableCTI_VARIABLES with this content:

cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1

Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with the CUT() function. But it only returns the first one, because it accepts a single character as an argument. How can I do it when I want to separate by two characters?

Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

I also tried using the FIELDQTY() function with no luck:

TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)}
TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)}
Source Link

Asterisk : Using Cut with multiple delimeter

I have a small problem. I have a variables getting from AGI like this. CTI_VARIABLES: "cti_CallDirection=1@;cti_ContractNumber=00202417@;cti_TransferVDN=48195@;cti_IvrButton=1" Each different variable within this variable is marked "@;" separated by . I’m trying to separate them with CUT. I think CUT only operates one of them because it accepts char. How can I do it when I want to separate by two characters? Here is my dialplan code

exten => addheader,1,NoOp(CTI_VARIABLES: ${CTI_VARIABLES})
same => n,GotoIf($["${CTI_VARIABLES}" = ""]?noVariables)
same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@\;)})
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${TOTAL_VARS}])
same => n,Set(CURRENT_VAR=${CUT(CTI_VARIABLES,@\;,${COUNTER})})
same => n,Set(VAR_NAME=${CUT(CURRENT_VAR,\=,1)})
same => n,Set(VAR_VALUE=${CUT(CURRENT_VAR,\=,2)})
same => n,Set(PJSIP_HEADER(add,${VAR_NAME})=${VAR_VALUE})
same => n,NoOp(${VAR_NAME}: ${VAR_VALUE})
same => n,Set(COUNTER=$[${COUNTER}+1])
same => n,EndWhile
same => n(noVariables),NoOp(No CTI Variables Set)

If there is a different method you suggest, I can use it. Thank you

I tried

1 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,\@\;)})
2 . same => n,Set(TOTAL_VARS=${FIELDQTY(CTI_VARIABLES,@;)})

But none of them separated the two characters with CUT.

AltStyle によって変換されたページ (->オリジナル) /