What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Variable isn't defined

Variable isn't defined
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Variable isn't defined
But parseInt isn't the best solution for this. parseInt gets the first integer from a string, and that's not always what you need. Here are some proofs:
code:
parseInt("85") -> 85 //parseInt finds the integer 85.
parseInt("85.999") -> 85 //parseInt searches until a non-decimal or period is found, and thus only finds 85.
parseInt("      85.999") -> 85 //parseInt searches from the first non-whitespace character, and finds 85.
parseInt("a85.999") -> NaN //parseInt returns NaN if the first character is not a decimal or a white-space character.
Thus, if you have decimals in your "textual number", parseInt will discard them. However, parseInt is a good choice to convert from numeric systems to the decimal system. Like:
code:
parseInt("0xFF", 16) -> 255 //From hexadecimal to decimal
parseInt("100", 8) -> 64 //From octal to decimal
parseInt("1010", 2) -> 10 //From binary to decimal

Of course, in this case you are allowed to choose, since you expect that the XML contains only integers. But personally, I rely more on the type conversions of JScript than on parseInt, especially because parseInt does more than you actually need.

This post was edited on 11-04-2007 at 10:30 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-04-2007 10:28 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Variable isn't defined - by SnuZZer on 11-02-2007 at 07:40 PM
RE: Variable isn't defined - by Matti on 11-02-2007 at 08:17 PM
RE: Variable isn't defined - by SnuZZer on 11-02-2007 at 08:43 PM
RE: Variable isn't defined - by Matti on 11-03-2007 at 09:55 AM
RE: Variable isn't defined - by SnuZZer on 11-03-2007 at 03:43 PM
RE: Variable isn't defined - by roflmao456 on 11-03-2007 at 06:42 PM
RE: Variable isn't defined - by Felu on 11-04-2007 at 03:57 AM
RE: Variable isn't defined - by Matti on 11-04-2007 at 10:28 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