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

Check message
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Check message
Hi.
I'm from Denmark and my english isn't good, but i'll try.
I try to check if the first line contains "Antal tegn sendt:".
This is the message I'm sending:
        Antal tegn sendt:     
   A     = 8        B     = 114        C     = 6
   D     = 8        E     = 14        F     = 2
   G     = 6        H     = 2        I     = 4
   J     = 2        K     = 2        L     = 6
   M     = 2        N     = 12        O     = 2
   P     = 2        Q     = 2        R     = 6
   S     = 6        T     = 14        U     = 2
   V     = 2        W     = 2        X     = 2
   Y     = 2        Z     = 2
   Ialt er der sendt 232 tegn           


But it says that the firs line doesn't contains "Antal tegn sendt:".


Here is my code:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
     if (Message.match(/^Antal tegn sendt:($|\s+)/m) == null)
     {
        Lille = Message.toLowerCase();
   
        for (i=0;i<Lille.length;i++)
        {
            if (Lille.charCodeAt(i) < "123" && Lille.charCodeAt(i) > "96")
            {
                Alfabet[Lille.charCodeAt(i)-97]++;
            }
        }
    }
   
    return Message;
}

Addition: Parts of the code are italic, if it isn't it is smilies

Thanks in advance

This post was edited on 11-11-2006 at 04:05 PM by SnuZZer.
11-11-2006 04:01 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Check message
Anywayay, I already made a script like this some time ago. Code is available here: http://code.google.com/p/lettercount/

EDIT: Code removed, I was wrong :P

This post was edited on 11-11-2006 at 04:13 PM by Ezra.
[Image: 1-0.png]
             
11-11-2006 04:10 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Check message
Hi.
Ezra, if I use the code you have posted then it doesnt count if the message doesn't contain "Antal tegn sendt:".

I know that the script excists, but sometimes i copy a script just to learn.
11-11-2006 04:14 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Check message
quote:
Originally posted by SnuZZer
Hi.
Ezra, if I use the code you have posted then it doesnt count if the message doesn't contain "Antal tegn sendt:"

Yeah, already found that out :-P, and removed my code.

You can look at the source from my script to see what's wrong.
I can't see what's wrong by looking at this small snippet. Are you sure you didn't make a typo or something?
[Image: 1-0.png]
             
11-11-2006 04:17 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Check message
Hi.
I have looked many times, but I can't find out what I'm doing wrong.
11-11-2006 04:30 PM
Profile E-Mail PM Web Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: Check message
you tried with "indexOf"  ?

Message.indexOf(string,start)

It gives back the position of the first time that appears the character indicated by parameter in string. If it does not find the character in string it gives back -1. The second parameter is optional and serves to indicate from that position is desired that begins the search.

:)
11-11-2006 05:05 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Check message
Hi.
What shall I shift "start" out with?

Here is my code:
code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    var Tjek = Message.indexOf("Antal tegn sendt:",start);
   
    if(Tjek == "-1")
    {
        Lille = Message.toLowerCase();
   
        for (i=0;i<Lille.length;i++)
        {
            if (Lille.charCodeAt(i) < "123" && Lille.charCodeAt(i) > "96")
            {
                Alfabet[Lille.charCodeAt(i)-97]++;
            }
        }
    }
   
    return Message;
}
11-11-2006 05:23 PM
Profile E-Mail PM Web Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: Check message
start is a numeric value that it indicates  where began to look for the string.
if you wishes to look for from the beginning, start be zero
11-11-2006 05:51 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Check message
Hi.
It works. Thanks!
11-11-2006 06:22 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


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