StrLen
Counts the number of characters in a string.
Syntax
StrLen( StringValue );
Parameters
| Parameter Name | Type | Description | Optional? | Default Value |
|---|---|---|---|---|
| StringValue | String | The string to interrogate. | No | n/a |
Output
The number of characters in the supplied string.
Use Case
Knowing the length of a string alone is not terribly useful, but you can use it for a wide variety of further expressions. For example, when asking a user to create a password for a new e-mail account, you might want to set a minimum and maximum length requirement:
( StrLen( MyPassword ) >= 5 )
This part takes care of the minimum limit; if the password supplied is 5 or more characters, the above expression evaluates to True. Using the And operator, we can join this initial expression to another that sets the upper limit.
( StrLen( MyPassword ) >= 5 ) & ( StrLen( MyPassword ) < 20 )
Now, if the password is 5 or more characters in length, but less than 20 characters, the above expression evaluates to True, meaning that the password suits our purposes.