Returns a copy of a given string with a substring inserted into a chosen position.


GML Code Example

string_insert(substr, str, index);

Argument Description
substr The substring to be inserted.
str The string to be copied.
index The position in characters of the string to insert the substring.

Returns: String


With this function you can create a new string made up of two strings, where one has been inserted into the other at a given position. It can be useful, for example, to add a user name into a predefined text and so make the player of your game feel more involved in the action.


GML Code Example

str2 = string_insert(username, "Hello, , how are you?", 7);

This will insert the string in the "username" variable into the given phrase with the resulting string looking like this: "Hello, NAME, how are you?".

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