String Length (Strlen)
What is it?
The Strlen function counts and returns the number of characters in a string argument. The number of characters is also known as the string’s Length.
What is the Syntax?
The Strlen function’s syntax is as follows:
Strlen( Argument );
Why might I want to use this?
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.
<< Previous: String Related Functions | Next: Substring (Substr) >>