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

Command Parsing Help
Author: Message:
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Command Parsing Help
Here's a good function that has always worked for me:

EDIT: put the function in and then use:
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
     return parseCommands(Message,ChatWnd);
}

code:
function parseCommands(sMessage,ChatWnd){
      if (sMessage.charAt(0) == '/'){
            if(sMessage.charAt(1) == '/'){
                  return sMessage;
            } else {
                  var firstSpace = sMessage.search(' ');
                        if(firstSpace == -1){
                              var command = sMessage.toLowerCase().substr(1);
                              var params = '';
                        } else {
                              var command = sMessage.toLowerCase().substr(1, firstSpace-1);
                              var params = sMessage.toLowerCase().substr(firstSpace+1);
                        }
                              switch(command) {
                                    case 'whatever':
                                          //Do whatever here, but leave the next two lines. Add them to each case. They're important =)
                                          sMessage = '';
                                          break;
                                    }
                              }
            return sMessage;
      }
}

This post was edited on 06-27-2006 at 09:13 PM by deAd.
06-27-2006 09:09 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Command Parsing Help - by Stigmata on 06-27-2006 at 09:01 PM
RE: Command Parsing Help - by deAd on 06-27-2006 at 09:09 PM
RE: Command Parsing Help - by J-Thread on 06-27-2006 at 09:14 PM
RE: Command Parsing Help - by Stigmata on 06-27-2006 at 09:25 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