What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Release] Exit WLM

[Release] Exit WLM
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: RE: RE: RE: [Release] Exit Messenger - script attached
quote:
Originally posted by CookieRevised
almost, since that regular expression does not work properly.

What you need to take in account:

- a command always starts with only 1 slash "/" (not two, or more)
^^ your reg exp fails here since you don't exclude second or more slashes.

- after the slash there can not be a spacing character
^^ your reg exp fails here since you define the exclussion list to be 0 or more times ("*") when it should be 1 or more times ("+").
PS: a space (ascii 32) is also a spacing character ("\s") so you don't need to define that seperatly in the exclussion list.


- commands should be case insensitive, but parameters are not!
^^ your reg exp fails here since you don't lowercase the command. Yet you use the case insensitive marker. But this does not do anything, since there are no characters in the regular expression. That marker is for searching on all cases, not to convert cases.

- after the command there can be many spacing characters. In many cases (if not all), the user/coder simply wants the parameter to begin without any spacing characters. But Plus!'s default behaviour is to take every occuring spacing character after the first spacing character after the command as part of the parameter (though not that usefull for almost all scripts).
^^ your reg exp fails here since you don't specify a spacing character ("\s") but only a space (ascii 32).

- a parameter can contain multiple lines.
^^ your reg exp fails here too since you check on 'any' character ("."),  but 'any' character does not include new line characters ("\n").
Thanks for that, I always miss the minor details but at least you are there to fix me up <3

quote:
A proper generic regular expression to seperate the command and parameter:

code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMessage) !== null) {
        var command = RegExp.$1.toLowerCase();
        var parameter = RegExp.$2;
        switch (command) {
            case 'quit':
                // <- Do something when the user typed the command quit
                return '';
            case 'exit':
                // <- Do something when the user typed the command exit
                return '';
            case 'cancel':
                // <- Do something when the user typed the command cancel
                return '';
        }
    }
}

Thanks, I'm noting this one down.


quote:
If you only have 1 command in your script (eg: /explode) your can use something like:
code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/explode\s*([\s\S]*)$/i.exec(sMessage) !== null) {
        var parameter = RegExp.$1;
        // <- Do something when the user typed the command explode
        return '';
    }
}
In above two snippets:
- to let the parameter include all leading spacing characters like Plus! nativly does, change  \s*  to  \s?

;)

I'm sorry to tell you but your expression also fails I'm sorry to say (but not as much as mine :P). It should be this:
code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
    if (/^\/explode\s*([\s\S]*)$/.exec(sMessage) !== null) {//not case insensitive
        var parameter = RegExp.$1;
        // <- Do something when the user typed the command explode
        return '';
    }
}
Otherwise "/EXPLODE" would also work and any other instance of "/explode" that uses whichever case wherever through the word.  I'll let you off this once though ;)
[Image: markee.png]
12-19-2006 02:02 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Release] Exit WLM - by Spunky on 11-13-2006 at 03:07 AM
RE: [Release] Exit WLM - by NanaFreak on 11-13-2006 at 03:12 AM
RE: [Release] Exit WLM - by MicroWay on 11-13-2006 at 03:16 AM
RE: [Release] Exit WLM - by markee on 11-13-2006 at 03:19 AM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 03:21 AM
RE: [Release] Exit WLM - by matty on 11-13-2006 at 03:51 AM
RE: [Release] Exit WLM - by markee on 11-13-2006 at 03:58 AM
RE: [Release] Exit WLM - by CookieRevised on 11-13-2006 at 04:06 AM
RE: [Release] Exit WLM - by matty on 11-13-2006 at 05:22 AM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 07:48 PM
RE: [Release] Exit WLM - by Matti on 11-13-2006 at 08:16 PM
RE: [Release] Exit WLM - by Spunky on 11-13-2006 at 08:23 PM
RE: [Release] Exit Messenger - script attached - by CookieRevised on 11-15-2006 at 12:14 AM
RE: RE: [Release] Exit Messenger - script attached - by Jesus on 12-18-2006 at 01:37 PM
RE: RE: RE: [Release] Exit Messenger - script attached - by markee on 12-18-2006 at 02:06 PM
RE: RE: RE: [Release] Exit Messenger - script attached - by CookieRevised on 12-19-2006 at 12:27 AM
RE: RE: RE: RE: [Release] Exit Messenger - script attached - by markee on 12-19-2006 at 02:02 AM
RE: [Release] Exit WLM - by Spunky on 11-15-2006 at 12:29 AM
RE: [Release] Exit WLM - by CookieRevised on 11-15-2006 at 01:17 AM
RE: [Release] Exit WLM - by Aristide on 12-17-2006 at 01:56 PM
Re; [Release] Exit WLM - by BraydenP on 12-18-2006 at 12:37 PM
RE: [Release] Exit WLM - by CookieRevised on 12-19-2006 at 02:06 AM
RE: [Release] Exit WLM - by Spunky on 12-19-2006 at 02:08 AM
RE: [Release] Exit WLM - by warmth on 12-22-2006 at 11:38 PM
RE: [Release] Exit WLM - by Spunky on 12-23-2006 at 01:27 AM
RE: [Release] Exit WLM - by warmth on 12-23-2006 at 08:33 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