string_length(str)

str = The string of which you want to find the length of.

 

Example #1:

inputstringlen = string_length("Check the length");

 

In the above example inputstringlen will hold the number of characters of the string in string_length, which in this case would be 16 - ("Check the length" is 16 characters long). This function is particularly useful for counting the number of characters a player has input:

 

Example #2:

/* This will check if the player's name is more than 7 chars,

/  if so the player must type a different name less that 7 characters. */

playername=get_string("What is your name?","Nick");

while (string_length(playername) > 7) // Check length of string

{

show_message("NAME TOO LONG! NO MORE THAN 7 CHARACTERS PLEASE!");

playername=get_string("What is your name?","Bob");

}

 

Revision #1