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

Value comparison in UCCX 7 script

Andrew Skelly
Level 7
Level 7

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?

Please rate helpful posts by clicking the thumbs up!
2 Accepted Solutions

Accepted Solutions

Tanner Ezell
Level 4
Level 4

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

View solution in original post

Gergely Szabo
VIP Alumni
VIP Alumni

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)).

View solution in original post

3 Replies 3

Tanner Ezell
Level 4
Level 4

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

Gergely Szabo
VIP Alumni
VIP Alumni

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)).

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

Please rate helpful posts by clicking the thumbs up!