[Release] Capitals and full stops(Updated!)V1.1 - 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: [Release] Capitals and full stops(Updated!)V1.1 (/showthread.php?tid=66567) [Release] Capitals and full stops(Updated!)V1.1 by Jimbo on 09-23-2006 at 04:42 PM
Well, this is my first script RE: [Release] Capitals and full stops by Chris4 on 09-23-2006 at 05:06 PM
Nice work RE: [Release] Capitals and full stops by Jimbo on 09-23-2006 at 05:08 PM good idea, will try to do it don't hold me to it though as it is my first script RE: [Release] Capitals and full stops by Zahid™ on 09-23-2006 at 06:39 PM Already a script that does this: http://www.msgpluslive.net/scripts/browse/index.php?act=view&id=35 RE: [Release] Capitals and full stops by Jimbo on 09-24-2006 at 07:00 AM
oh damn, well mines going to have a UI and also some extra features. hopefully it will be better than that 1 RE: [Release] Capitals and full stops by NanaFreak on 10-01-2006 at 07:38 AM
Ok there is a new release of Capitals and Full Stops for you all RE: [Release] Capitals and full stops(Updated!)V1.1 by xxhannahxx on 10-20-2006 at 07:31 PM Kool scipt Jimbodude and Nanafreak, maybe you could make the whole message uppercase? RE: [Release] Capitals and full stops(Updated!)V1.1 by Jimbo on 10-20-2006 at 07:33 PM Ok, good idea, will do it in the next update RE: [Release] Capitals and full stops(Updated!)V1.1 by Baggins on 10-20-2006 at 09:02 PM wtf is a full stop? RE: [Release] Capitals and full stops(Updated!)V1.1 by prashker on 10-20-2006 at 09:06 PM
quote: . RE: [Release] Capitals and full stops(Updated!)V1.1 by Baggins on 10-20-2006 at 10:45 PM oh RE: [Release] Capitals and full stops(Updated!)V1.1 by CookieRevised on 10-21-2006 at 03:02 AM
JimboDude I'll comment on various things so you know where things can be improved and why, so you can apply those things in your future scripts too. As further reference I suggest to read the Official JScript 5.6 reference in the msdn library and/or download the Official Scripting Documentation from Windows. Terms in italic in this post can be found in those references, look them up Anyways: code:You can simplify all that.... No need for calculating the length of "?", "!", etc... it's always 1 anyways thus: code:"something-1" can be written as "--something", thus: code:Don't use substr to grab 1 character inside a string, use charAt instead: code: Instead of grabbing the last character each time again, assign the last character to a variable and compare that variable with whatever you need to compare it with: code:Since you compare that same last character again and again with another character, you can turn this all around and check if that last character can be found into the string "?!:.;,". If so, you have a match if not you don't have a match. Use indexOf for this: code: So now code:is reduced to: code:And if you know regular expressions this can be simplified even more....: code: Other stuff: - remove that "Message = null" line. It is not needed. And luckally it is not executed either as that will otherwise produce an error. See this post for more info (and of course the Plus! Scripting Documentation). - the case where (caps=="on" && dot=="on") doesn't check for already existing dots, commas, question marks, etc Suggestions: - Instead of having 4 IF THEN ELSE structures, split them up and examine exactly what each function does with the sentence in what case. You'll find that you will only need 2 IF THEN ELSE structures since you will only actually do something when a setting is on, not when it is off. You also do not need the ELSE case at all. Result: highlight to see it code: Bugs still to fix: - You need to check if the message is not a command (messages beginning with "/" or even "!"). - Check individual lines (you could do this by splitting your message up into an array using the method split with delimiter "\n") - If you define an ActiveX object, make sure it is always defined. Your code contains several occasion where you use an ActiveX object (WSH), but which isn't defined since you have placed it inside an IF THEN ELSE structure (see OnEvent_MenuClicked function). More things you can make better: code:For something like this you better use the switch statement. code:Put the same common lines outside the IF THEN ELSE structure. Then you'll also see that you can reduce the IF THEN ELSE structure to only 1 line using the conditional (ternary) operator. eg: to switch between two states: myvar = (myvar == "1") ? "2" : "1" But instead of using strings to indicate the states of the options, use booleans. They are way easier to work with and will reduce the code even further. eg: to switch between two states: myvar = !myvar Using booleans will extremely shorten all your code if you use it wisely. RE: [Release] Capitals and full stops(Updated!)V1.1 by Jimbo on 10-21-2006 at 01:35 PM Ok thanks for all the help cookie, will try to use booleans and all them things you mentioned in the next update(and maybe som more scripts from me!) RE: [Release] Capitals and full stops(Updated!)V1.1 by MoonGoose on 10-21-2006 at 07:08 PM nice work, but sometimes I don't get a capital in the beginning. It is turned on!!! RE: [Release] Capitals and full stops(Updated!)V1.1 by Jimbo on 10-22-2006 at 10:07 AM
erm, try replacing the first function with this: code: |