Finding the length of a string variable

Unanswered Question
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
toddmmccall Fri, 04/13/2007 - 07:35

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-

Actions

This Discussion