-
-
Notifications
You must be signed in to change notification settings - Fork 18
string_length
CryoEagle edited this page Dec 26, 2018
·
3 revisions
Returns the number of characters comprising a given string.
string_length(str)
Argument | Description |
---|---|
string str |
The string to measure the number of characters of |
Returns: int
This function returns the number of characters comprising a given string. It can be useful for things like working out when to limit a custom text entry's character length (eg: capping a player's name to 10 characters). Remember that this is different to string_width in that it measures the number of characters in the string, not its width as drawn on the screen in pixels.
string name = get_string("Enter your name", "Unnamed");
if (string_length(name) > 10)
{
name = string_copy(name, 1, 10);
}
This will check if the string of name is greater than ten characters and if it is, it will copy and use the first ten characters only.
Back to strings