Skip to content

string_insert

CryoEagle edited this page Dec 26, 2018 · 6 revisions

string_insert

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

Syntax:

string_insert(substr, str, index)
Argument Description
string substr The substring to be inserted
string str The string to be copied
int index The position in characters of the string to insert the substring

Returns: string

Description

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.

Example:

string username = "Bob";
string str = 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, Bob, how are you?".

Back to strings

Clone this wiki locally