This document was generated from CDN thread
Created by: Fabien Damien on 19-01-2009 08:34:23 AM
Hello eveyone,
In CVP studio, I'm configuring a decision element in which I'm trying to compare the length of an element data to a constant number. For example if the number entered in the element data is equal to seven digits then it's a valid number or else the number is not valid.
Can this be done without using java coding?
Thanks for your assistance,
Fabien
Edited by: Fabien Damien on Jan 19, 2009 6:21 AM
Edited by: Fabien Damien on Jan 19, 2009 6:27 AM
Subject: Re: String length Comparison
Replied by: Elam Birnbaum on 26-01-2009 06:14:13 PM
Providing a copy of the answer I made to this question in another post:
There is no built-in way to get the length of a string without programming unfortunately. Decision editor allows you to do String comparison, but not get the length of the string.
Here is an idea that should work in your situation, though, which involves a number. You can make a decision editor decision check if the number is greater than 999999 and if it is, the number has 7 digits. You can write a cascading decision such that you have different exit states based on the number of digits in the value. For example:
if num > 999999 then return 7-digit
else if num > 99999 then return 6-digit
else if num > 9999 then return 5-digit
else if num > 999 then return 4-digit
else if num > 99 then return 3-digit
else if num > 9 then return 2-digit
else return 1-digit
Hope this helps!
Subject: Re: String length Comparison
Replied by: Fabien Damien on 29-01-2009 09:17:46 AM
Elam Thanks for your feedback,
An easier solution would be to use two different decision elements, in the first if the number is greater than 999999 then it's valid else invlalid. then connect the valid state to another decision element and this time check if the element data is < 9999999. if it is than it is valid else invalid.
Thanks Tac support,
Cheers,
Edited by: Fabien Damien on Jan 29, 2009 4:20 AM