What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Capital letter & a dot

Capital letter & a dot
Author: Message:
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Capital letter & a dot
I had a go at it, but my mind isn't working very well today so the following is most likely highly inefficient.

code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
     return punctuate(sMessage);
}

function punctuate(s)
{
    var sentences = s.split(" ");
    for (var i = 0; i < sentences.length; i++)
    {
        if (i == sentences.length - 1 && isin(sentences[i].charAt(sentences[i].length - 1), "abcdefghijklmnopqrstuvwxyz0123456789"))
            sentences[i] =  sentences[i] + ".";
        if (i == 0)
            sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
        else
            if (isin(sentences[i-1].charAt(sentences[i-1].length - 1), ".?!"))
                sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].substr(1);
    }
    return sentences.join(" ");
}

function isin(needle, haystack)
{
    for (var i = 0; i < haystack.length; i++)
        if (haystack.charAt( i ) == needle)
            return true;
    return false;
}


If it's easier to read/copy/paste I pastebinned it:

http://pastebin.ca/75734

This post was edited on 06-30-2006 at 02:35 PM by segosa.
The previous sentence is false. The following sentence is true.
06-30-2006 02:34 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Capital letter & a dot - by Bmw1000c on 06-27-2006 at 03:48 PM
RE: Capital letter & a dot - by Lou on 06-27-2006 at 03:56 PM
RE: Capital letter & a dot - by Twozzok on 06-27-2006 at 03:57 PM
RE: Capital letter & a dot - by qgroessl on 06-27-2006 at 03:58 PM
RE: Capital letter & a dot - by Mike on 06-27-2006 at 04:01 PM
RE: Capital letter & a dot - by Menthix on 06-27-2006 at 04:05 PM
RE: Capital letter & a dot - by matty on 06-27-2006 at 04:06 PM
RE: Capital letter & a dot - by Bmw1000c on 06-27-2006 at 04:13 PM
RE: Capital letter & a dot - by upsfeup on 06-27-2006 at 04:15 PM
RE: Capital letter & a dot - by hmaster on 06-27-2006 at 04:15 PM
RE: Capital letter & a dot - by Bmw1000c on 06-27-2006 at 04:27 PM
RE: Capital letter & a dot - by upsfeup on 06-27-2006 at 04:31 PM
RE: Capital letter & a dot - by Bmw1000c on 06-27-2006 at 04:34 PM
RE: Capital letter & a dot - by steve_xrcc on 06-30-2006 at 10:24 AM
RE: Capital letter & a dot - by upsfeup on 06-30-2006 at 12:19 PM
RE: Capital letter & a dot - by segosa on 06-30-2006 at 02:34 PM
RE: Capital letter & a dot - by Bmw1000c on 06-30-2006 at 04:06 PM
RE: Capital letter & a dot - by Sypher on 06-30-2006 at 04:20 PM
RE: Capital letter & a dot - by Bmw1000c on 06-30-2006 at 04:22 PM
RE: Capital letter & a dot - by Jellings on 06-30-2006 at 10:03 PM
RE: RE: Capital letter & a dot - by segosa on 07-01-2006 at 06:08 AM
RE: Capital letter & a dot - by steve_xrcc on 07-01-2006 at 06:10 AM
RE: Capital letter & a dot - by Bmw1000c on 07-01-2006 at 09:34 AM
RE: Capital letter & a dot - by Tartooob on 07-01-2006 at 11:59 AM
RE: Capital letter & a dot - by Alexcess on 07-01-2006 at 04:17 PM
RE: Capital letter & a dot - by Sypher on 07-01-2006 at 04:56 PM
RE: Capital letter & a dot - by hmaster on 07-01-2006 at 04:59 PM
RE: RE: Capital letter & a dot - by Tartooob on 07-02-2006 at 12:00 PM
RE: Capital letter & a dot - by Dark_Nightmare on 07-02-2006 at 08:20 PM
RE: RE: Capital letter & a dot - by Tartooob on 07-03-2006 at 10:13 AM
RE: Capital letter & a dot - by dylan! on 07-02-2006 at 08:43 PM
RE: Capital letter & a dot - by Mentality on 07-02-2006 at 09:03 PM
RE: Capital letter & a dot - by dylan! on 07-02-2006 at 09:11 PM
RE: Capital letter & a dot - by Mentality on 07-02-2006 at 09:22 PM
RE: Capital letter & a dot - by Sunshine on 07-03-2006 at 04:23 PM
RE: RE: Capital letter & a dot - by Dark_Nightmare on 07-04-2006 at 02:25 PM
RE: Capital letter & a dot - by Sunshine on 07-04-2006 at 02:37 PM
RE: Capital letter & a dot - by Jellings on 07-04-2006 at 04:22 PM
RE: Capital letter & a dot - by Farkie on 07-04-2006 at 10:21 PM
RE: Capital letter & a dot - by AmbulanceX on 07-08-2006 at 03:27 PM
RE: Capital letter & a dot - by AmbulanceX on 07-08-2006 at 04:03 PM
RE: Capital letter & a dot - by XAaronX on 07-29-2006 at 02:38 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