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

Calculator to friends
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: Calculator to friends
@Pinecone: That looks like a very simple implementation, although I'd suggest you could optimize that code by breaking out of the loop as soon as you found an invalid character:
code:
    for (j=0; j<Msg.length; j++) if ((Msg.charCodeAt(j) < 40) || (Msg.charCodeAt(j) > 57)) {
        Valid = false;
        break;
}
@Spunky: Indeed, you can simply strip out all alphabetical characters and other possibly malicious characters. However, I'd suggest you to improve your stripping algorithm then: instead of looping through the whole array everytime !calc is received, you could create one single RegExp at start-up formed by a single loop which will strip all unwanted characters:
code:
var iChars = array("!", "£", "\\$", "\&", "\\?", "\>", "\<", ",", "\\.", "@", "\'", ":", ";", "\\[", "\\]", "=", "\\|", "`", "¬", "\\\\", "\"");
var reStrip = new RegExp("[a-z" + iChars.join("") + "]+", "gi");

/* ... */
Message = Message.substr(6);
Message = Message.replace(reStrip, "");
try{
/* ... */

And what if you'd want to extend such a script and make things like sin(60), cos(60), sqrt(64) work? Well, good luck to both of you if you're looking to extend your scripts. :P

This post was edited on 12-22-2008 at 10:59 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!
12-22-2008 10:58 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Calculator to friends - by mrfireman on 12-18-2008 at 12:37 AM
RE: Calculator to friends - by toddy on 12-18-2008 at 01:35 AM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 01:44 PM
RE: Calculator to friends - by matty on 12-18-2008 at 04:04 PM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 05:56 PM
RE: Calculator to friends - by matty on 12-18-2008 at 06:01 PM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 06:49 PM
RE: Calculator to friends - by matty on 12-18-2008 at 07:51 PM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 08:13 PM
RE: Calculator to friends - by matty on 12-18-2008 at 08:21 PM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 09:03 PM
RE: Calculator to friends - by matty on 12-18-2008 at 09:05 PM
RE: Calculator to friends - by Chrono on 12-18-2008 at 09:12 PM
RE: Calculator to friends - by matty on 12-18-2008 at 09:15 PM
RE: Calculator to friends - by mrfireman on 12-18-2008 at 09:22 PM
RE: Calculator to friends - by WDZ on 12-19-2008 at 06:06 AM
RE: Calculator to friends - by Matti on 12-19-2008 at 08:31 AM
RE: RE: Calculator to friends - by segosa on 12-20-2008 at 05:11 AM
RE: Calculator to friends - by mrfireman on 12-19-2008 at 10:12 PM
RE: Calculator to friends - by TheBlasphemer on 12-20-2008 at 09:33 PM
RE: Calculator to friends - by Pinecone on 12-21-2008 at 11:14 AM
RE: Calculator to friends - by Spunky on 12-21-2008 at 11:56 PM
RE: Calculator to friends - by Matti on 12-22-2008 at 10:58 AM
RE: Calculator to friends - by mrfireman on 12-22-2008 at 12:35 PM
RE: Calculator to friends - by mrfireman on 12-23-2008 at 05:18 PM
RE: Calculator to friends - by Pinecone on 12-23-2008 at 05:26 PM


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