cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Cisco Community Designated VIP Class of 2020

397
Views
0
Helpful
3
Replies
Beginner

Finding the length of a string variable

Guys,

I'm trying to find the length of a string variable in order to evaluate how much of it I will pass to the ICM call variable. I'm using the latest CRA editor and I'm at a loss. This variable value may contain numbers and commas.

Thanks

Bruce

3 REPLIES 3
Beginner

Re: Finding the length of a string variable

ICM has built in functions that allow enormous flexibility when working wit hstring variables.

To find the length of a variable, use the len() function. To find the length of part of a variable, you need more functions such as after(), before(), left(), right(), find(), substr()... etc.

Here is an example where I KNOW that the 10 character date is in the first 10 characters of my variable, but I don't know how many characters follow that date.

So, I use the subsring() function to return to me all of the characters after the 10 character date. Here is the standard usage of the substring function:

substr(s, i [, l])

Returns substring of s, beginning with i and continuing for l characters. The l is optional.

Here is how I would use it:

substr(variable1,11)

But I still don't know the lengh, su I use that within the len() function, like this:

len(substring(variable1,11))

Now I know how many characters follow the date value in my variable.

Here's another example. Lets say you have a comma in the variable, and you want to count all the characters after the comma. Use the after() function to find the first comma and count the rest of the variable length, like this:

len(after(",",variable1))

Another example: Lets say that you know the length of half of the variable in every occurance of the variable and that length is 26. Use this:

(len(variable1) - 26).

If you provide more specifics I might be able to come up with a few more methods for finding the length of a string variable. There are more tricks in evaluating a string, such as value(), text() and if().

-Todd-

Highlighted
Beginner

Re: Finding the length of a string variable

Todd,

Thanks for the reply. These methods can be used from withing the expression builder of an "IF" step?

Thanks

Bruce

Beginner

Re: Finding the length of a string variable

Todd,

Here's the issue and maybe you can help:

I'm having callers enter the date. I need to prepend this date with enough zeroes to total 12 characters. There is also an * that I'm using to delineate between $ and cents.

Thanks for the help

Bruce

CreatePlease to create content
Content for Community-Ad
FusionCharts will render here