cancel
Silver

## Value comparison in UCCX 7 script

I'm trying to put a piece of logic into a script that compares a customer entered value (string variable) against a static value (100000000).  The logic I have looks like this:

If (valueEntered > "10000000") then

However almost any value entered returns a True result.  So if I entered in 115, the script is seeing 115 as larger than 10000000 even though it is not.

I've tried to change the variable to an integer variable from string, but no luck.  Anybody have any ideas on how to make this work so that only those values that are truely greater than 10000000 return a True result?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Silver

## Value comparison in UCCX 7 script

You are comparing against a string ("10000000" is a string). Try:

if (valueEntered > 10000000)

or

if (Integer.parseInt(valueEntered) > 10000000)

Tanner Ezell www.ctilogic.com
Green

## Re: Value comparison in UCCX 7 script

Hi,

no, you cannot compare apples to oranges, Strings to Integers.

You can, however, cast a String into Integer. It's easy.

Integer.parseInt(stringValue)

So, in your case:

If (Integer.parseInt(valueEntered) > 100000000)

etc.

http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29

G.

P.S. Integer is fine up to 2,147,483,647; for higher numbers use Long ~ (Long.parseLong(valueEntered)).

3 REPLIES
Silver

## Value comparison in UCCX 7 script

You are comparing against a string ("10000000" is a string). Try:

if (valueEntered > 10000000)

or

if (Integer.parseInt(valueEntered) > 10000000)

Tanner Ezell www.ctilogic.com
Green

## Re: Value comparison in UCCX 7 script

Hi,

no, you cannot compare apples to oranges, Strings to Integers.

You can, however, cast a String into Integer. It's easy.

Integer.parseInt(stringValue)

So, in your case:

If (Integer.parseInt(valueEntered) > 100000000)

etc.

http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#parseInt%28java.lang.String%29

G.

P.S. Integer is fine up to 2,147,483,647; for higher numbers use Long ~ (Long.parseLong(valueEntered)).

Silver

## Value comparison in UCCX 7 script

Thank you both!!  I had to change it to int.parseInt but that works perfectly and is returning an accurate response.

550
Views
0