Don't click here unless you want to be banned.

LSL Wiki : ExampleIsInteger

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org
The function below determines if data passed to it is an integer or not. Useful when parsing notecards, etc...

integer IsInteger(string data)
{
     return ((llParseString2List(data, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], []) == []) && (data != ""));
}

Example Function Usage:
integer IsInteger(string data)
{
     return ((llParseString2List(data, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], []) == []) && (data != ""));
}

default
{
    touch_start(integer t)
    {
        string data = "42";
        if(IsInteger(data))
        {
            llOwnerSay("Integer");
        }
        else
        {
            llOwnerSay("Not An Integer");
        }
    }
}

Example Non-Function Usage:
default
{
    touch_start(integer t)
    {
        string data = "42";
        if((llParseString2List(data, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], []) == []) && (data != ""))
        {
            llOwnerSay("Integer");
        }
        else
        {
            llOwnerSay("Not An Integer");
        }
    }
}


HomePage | Examples
There is no comment on this page. [Display comments/form]