string_last_pos_ext

This function will return the character position of an instance of a sub-string within a string, searching backwards through the string from the position given as the starting position. The function will return 0 if the search string is not found, or the position of the first character of the search string if it is. Keep in mind that for legacy support strings are indexed from 1, so 1 is the first position in the string, not 0 as you may expect.

 

Syntax:

string_last_pos_ext(substr, str, start_pos);

ArgumentTypeDescription
substrStringThe substring to look for in the string.
strStringThe string.
start_posRealThe starting position to search from.

 

Returns:

Real

 

Example:

if (string_last_pos_ext(",", text, 20) != 0)
{
    string_insert(name, text, string_last_pos_ext(",", text, 20));
}

The above code searches the string stored in the variable "text" for a comma before the 20th character, and if it finds one it inserts the substring "name" at that position.