string_right

right = string_right("Hello World", 4);   //  right == "orld"
right = string_right("Hello World", -4);  //  right == "o World"
string_right(str,num)
Returns a number of characters from the end of a string.
/// string_right(str,num)
//
//  Returns a number of characters from the end of a string.
//  If the number of characters given is negative,
//  the string will be shortened by that amount.
//
//      str         string of text, string
//      num         number of characters, real
//
/// GMLscripts.com/license
{
    if (argument1 < 0)
        return string_copy(argument0, 1 - argument1, string_length(argument0) + argument1);
    else
        return string_copy(argument0, 1 + string_length(argument0) - argument1, argument1);
}

Contributors: xot

GitHub: View · Commits · Blame · Raw