Invert GMLscripts.com

string_left

left = string_left("Hello World", 4);   //  left == "Hell"
left = string_left("Hello World", -4);  //  left == "Hello W"
string_left(str, num)
Returns a number of characters from the start of a string.
COPY/// @func   string_left(str, num)
///
/// @desc   Returns a number of characters from the start of a string.
///         If the number of characters given is negative, the string
///         will be shortened by that amount.
///
/// @param  {string}    str         string of text
/// @param  {real}      num         number of characters
///
/// @return {string}    shortened string
///
/// GMLscripts.com/license

function string_left(str, num)
{
    if (num < 0) {
        return string_copy(str, 1, string_length(str) + num);
    } else {
        return string_copy(str, 1, num);
    }
}

Contributors: xot

GitHub: View · Commits · Blame · Raw