cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
513
Views
5
Helpful
5
Replies

how to use ten or more posibles values in string variables?

diegorgarces
Level 1
Level 1

Hello !

Using UCCX 7.0 script editor how i can use ten or more posibles values in string variables?, for example

i´m try to do this:

If caller id is: 6767 compare with variable "number"

i want to variable number = 8900 or 6767or 8742 or 8812

variable number is string.

What can i do?

BR

5 Replies 5

Jonathan Schulenberg
Hall of Fame
Hall of Fame

Well there's a few ways of going about this. This is more of a Java programing question than a CCX question though.

One of the easier ways would be to just create a String-type variable with a comma separated list of values you want (e.g.  myString = "8900,6767,8742,8812"). From that you can use the Java .indexOf(String str) method to find the pattern you want within the variable.

Example:

Set myString = "8900,6767,8742,8812"

Set callingNumber = "6767"

If (myString.indexOf(callingNumber) >= 0)

  True

    Your logic here.

  False

    Your logic here.

Essentially, the indexOf method will return an integer value of the first occurrence within the String variable of the given pattern. In this case you don't care about this, what you care about is what happens if it doesn't find that pattern. In that case it returns a -1 value.

Most people use a Switch (Match Case) statement here and just list out the individual matching conditions they want. Without knowing the use case it's hard to tell you what the best way forward is.

Hi, Jonathan

Thank you, but can you be more explicit with the procedure?

When i could be do this steps inside script editor?

I don't understand what you are asking. I gave you exact steps and expression logic to use.

I know now, im a little confused when you talk me about java.

But now it´s working. Thank you very much !!!!!

Ah ok.  The CCX script is actually Java with a pretty UI slapped on top of it to make it easier for folks. The expression logic and anything fancy is where you need to break out "real" Java code is all.