Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker

String handling functions

The following functions deal with characters and string.

chr(val) Returns a string containing the character with code val for printing/displaying based on the current drawing font's character set codepage.
If no font is set, it will use default code page for the machine.
NOTE: This will change from machine to machine. If you need a specific codepage, then be sure to SET a font yourself at the start of your game..
If the font is a sprite font, no translation will be done.

ansi_char(val) Returns a string containing the character with raw BYTE value set.
NOTE: This will not, and should not be display, but it will save correctly to disk for use in encoding.

ord(str) Returns the asci code of the first character in str.
real(str) Turns str into a real number. str can contain a minus sign, a decimal dot and even an exponential part.
string(val) Turns the real value into a string using a standard format (no decimal places when it is an integer, and two decimal places otherwise).
string_format(val,tot,dec) Turns val into a string using your own format: tot indicates the total number of places and dec indicates the number of decimal places.
string_length(str) Returns the number of characters in the string.
string_byte_length(str) Returns the number of BYTES in the string. As strings are now held as UTF8, this means the length of the string is no longer it's BYTE size.
string_pos(substr,str) Returns the position of substr in str (0=no occurrence).
string_copy(str,index,count) Returns a substring of str, starting at position index, and of length count.
string_char_at(str,index) Returns the character in str at position index.
string_byte_at(str,index) Returns the raw byte value as a REAL at BYTE position index.
string_delete(str,index,count) Returns a copy of str with the part removed that starts at position index and has length count.
string_insert(substr,str,index) Returns a copy of str with substr added at position index.
string_replace(str,substr,newstr) Returns a copy of str with the first occurrence of substr replaced by newstr.
string_replace_all(str,substr,newstr) Returns a copy of str with all occurrences of substr replaced by newstr.
string_count(substr,str) Returns the number of occurrences of substr in str.
string_lower(str) Returns a lowercase copy of str.
string_upper(str) Returns an uppercase copy of str.
string_repeat(str,count) Returns a string consisting of count copies of str.
string_letters(str) Returns a string that only contains the letters in str.
string_digits(str) Returns a string that only contains the digits in str.
string_lettersdigits(str) Returns a string that contains the letters and digits in str.

The following functions deal with the clipboard for storing text.

clipboard_has_text() Returns whether there is any text on the clipboard.
clipboard_get_text() Returns the current text on the clipboard.
clipboard_set_text(str) Sets the string str on the clipboard.

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual