What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Convert Boolean to Numeric?

Convert Boolean to Numeric?
Author: Message:
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Convert Boolean to Numeric?
Personally I would use an inline if statement, as the other methods could potentially give you a -1 as your number.

You could even make it a function of the boolean object (but this is sort of overkill):
code:
Boolean.prototype.toInt = function () { return this ? 1 : 0; }

// to use it, just call the toInt member of a boolean object
function doSomethingWithBooleans() {
var bMyBoolean = true;
var nBoolAsInteger = bMyBoolean.toInt();
}

This post was edited on 10-04-2007 at 01:41 AM by deAd.
10-04-2007 01:37 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Convert Boolean to Numeric? - by stu on 10-03-2007 at 07:18 PM
RE: Convert Boolean to Numeric? - by Spunky on 10-03-2007 at 07:22 PM
RE: Convert Boolean to Numeric? - by stu on 10-03-2007 at 07:42 PM
RE: Convert Boolean to Numeric? - by markee on 10-03-2007 at 11:52 PM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 12:33 AM
RE: Convert Boolean to Numeric? - by markee on 10-04-2007 at 12:44 AM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 01:05 AM
RE: Convert Boolean to Numeric? - by deAd on 10-04-2007 at 01:22 AM
RE: Convert Boolean to Numeric? - by phalanxii on 10-04-2007 at 01:32 AM
RE: Convert Boolean to Numeric? - by deAd on 10-04-2007 at 01:37 AM
RE: Convert Boolean to Numeric? - by ShawnZ on 10-04-2007 at 02:04 AM
RE: Convert Boolean to Numeric? - by stu on 10-04-2007 at 03:04 AM
RE: Convert Boolean to Numeric? - by Spunky on 10-04-2007 at 11:51 AM
RE: Convert Boolean to Numeric? - by -dt- on 10-04-2007 at 02:21 PM
RE: Convert Boolean to Numeric? - by Matti on 10-04-2007 at 04:52 PM
RE: Convert Boolean to Numeric? - by markee on 10-04-2007 at 10:41 PM
RE: Convert Boolean to Numeric? - by Voldemort on 10-04-2007 at 11:01 PM
RE: Convert Boolean to Numeric? - by Spunky on 10-05-2007 at 12:40 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On