Shoutbox

from caps to lowercase - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: from caps to lowercase (/showthread.php?tid=74626)

from caps to lowercase by Jarrod on 05-23-2007 at 12:24 PM

in this script http://www.msgpluslive.net/scripts/view/71-Message-Enchanter
you can change all the letters to caps but can i mod it to make all the letters lowercase?


RE: from caps to lowercase by Menthix on 05-23-2007 at 12:31 PM

code:
    if(CommandIs == "Caps") {
    return Message.replace(Message, Message.toUpperCase());
    }
The above code transforms it to uppercase, so i assume adding the following directly below that code will give you a transform it to all lowercase:
code:
    if(CommandIs == "Lower") {
    return Message.replace(Message, Message.toLowerCase());
    }

And to make it work in the menu, search for:
code:
    if(ControlId == "Caps") {
        var CommandIs = "Caps";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }
Ande directly under that add:
code:
    if(ControlId == "Lower") {
        var CommandIs = "Lower";
        new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }

RE: from caps to lowercase by markee on 05-23-2007 at 01:15 PM

quote:
Originally posted by MenthiX
code:
    if(CommandIs == "Caps") {
    return Message.replace(Message, Message.toUpperCase());
    }
The above code transforms it to uppercase, so i assume adding the following directly below that code will give you a transform it to all lowercase:
code:
    if(CommandIs == "Lower") {
    return Message.replace(Message, Message.toLowerCase());
    }

I'm sorry but that can be done better, just try this:
code:
if(CommandIs == "Caps") return Message.toUpperCase();

and for lowercase:
code:
if(CommandIs == "Lower") return Message.toLowerCase();


It is just nicer to use these one liners (as well as being quicker).  Realistically the code of the script could be better, but this is sufficient for the script as it is.

Oh and just so you know, it is perfectly fine to not use {} for an if statement when there is only one line for inside of it.

quote:
Originally posted by MenthiX
And to make it work in the menu, search for:

    code:    if(ControlId == "Caps") {
    var CommandIs = "Caps";
    new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }

Ande directly under that add:

    code:    if(ControlId == "Lower") {
    var CommandIs = "Lower";
    new ActiveXObject('WScript.Shell').RegWrite(MsgPlus.ScriptRegPath + Email + "\\command",CommandIs);
    }


This isn't correct.  This is for the radio controls in the menu but you will have to personally edit the XML to add these....  The script itself only has "options" and "About" in the menu.

PS. Sorry MenthiX for disassembling your post how I did, but I wanted to make sure all the correct and best information was given, I hope you don't mind too much, it wasn't my intention.
RE: from caps to lowercase by Menthix on 05-23-2007 at 01:34 PM

You're right. I just took a quick look at the source and modified only the very minimal needed :). It will add a radiobutton instead of menuitem indeed, there is no real need to add a menuitem.


RE: RE: from caps to lowercase by vikke on 05-23-2007 at 02:01 PM

quote:
Originally posted by MenthiX
code:
    if(CommandIs == "Caps") {
    return Message.replace(Message, Message.toUpperCase());
    }
The above code transforms it to uppercase, so i assume adding the following directly below that code will give you a transform it to all lowercase:
code:
    if(CommandIs == "Lower") {
    return Message.replace(Message, Message.toLowerCase());
    }

Can't you just do:
code:
if(CommandIs == "Caps") {
   return Message.toUpperCase();
}

RE: from caps to lowercase by CookieRevised on 05-23-2007 at 06:56 PM

quote:
Originally posted by vikke
Can't you just do:
code:
if(CommandIs == "Caps") {
   return Message.toUpperCase();
}

that's what markee said ;)



[OFFTOPIC] tbh, this script is not well written (like many others in the database). This is very unfortunate as scripts in the database are also quite often used as programming examples for beginning scripters. I know it is very hard, if not impossible todo, but it would be nice if there was a quality mark/scale added for scripts in the database. Of course this would be somewhat biased (because the mark should be given by only a few people, who know how to make proper code), but it would benefit the quality of the scripts in the database. This scale is not a public rating as imho public ratings (like it is now) don't say a thing about the quality of a script and extremely depend on the amount of downloads...... As it currently is: if a script has a bad rating, it even rates higher and is listed higher than a script with no rating.[/OFFTOPIC]