Raised This Month: $ Target: $400
 0% 

[USEFUL FUNCTION] StrToBool


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Olly
Senior Member
Join Date: Mar 2007
Location: UK
Old 05-16-2007 , 21:36   [USEFUL FUNCTION] StrToBool
Reply With Quote #1

Code:
/*****************************************************************
 * StrToBool
 *
 * @breif Converts a string (1|0|on|off) to bool
 * @params String:input string bool
 * @return true|false
 *****************************************************************/
bool:StrToBool(String:input[])
{
    if(StrContains(input, "1") != -1 || StrContains(input, "on") != -1)
    {
        return true;
    }
    else if(StrContains(input, "0") != -1 || StrContains(input, "off") != -1)
    {
        return false;
    }
return false;
// YAY!
}
Note for this to work you MUST leave in '// YAY!' without it, it wont compile

I know its a simple function, but meh, saves someone else needing to type it all out

Hope its as usefull as the title makes out

Last edited by Olly; 05-16-2007 at 22:28. Reason: Because i can
Olly is offline
Send a message via MSN to Olly
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode