InsertString

From NWN Lexicon
Jump to navigationJump to search

InsertString(string, string, int)

This function will insert a string into the destination string at the position indicated by nPosition.

string InsertString(
    string sDestination,
    string sString,
    int nPosition
);

Parameters

sDestination

String to insert into.

sString

String to insert.

nPosition

Index position to insert at.

Description

This function inserts a string into another string.

Remarks

Prior to version 1.26 this function would instead overwrite vice insert.

Known Bugs

This function fails to add sString at the end of the sDestination and returns sDestination only. See example 2.

Version

1.26

Example

string s1 = "Bacon and spam";
string s2 = ", ham";
string s3 = InsertString(s1, s2, 5);
//s3 = "Bacon, ham and spam"
string s1 = "foo";
string s2 = "bar";
string s3 = InsertString(s1, s2, 3);
//s3 = "foo"

See Also


 author: Michael Nork, editors: Charles Feduke, Mistress, additional contributors: Iceberg, Fireboar