Returns the number of characters comprising a given string.


GML Code Example


Argument Description
str The string to measure the number of characters of.

Returns: Real


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.


GML Code Example

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: Strings

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here