Check message - 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: Check message (/showthread.php?tid=68290)
Check message by SnuZZer on 11-11-2006 at 04:01 PM
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
RE: Check message by Ezra on 11-11-2006 at 04:10 PM
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
RE: Check message by SnuZZer on 11-11-2006 at 04:14 PM
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.
RE: Check message by Ezra on 11-11-2006 at 04:17 PM
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 , 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?
RE: Check message by SnuZZer on 11-11-2006 at 04:30 PM
Hi.
I have looked many times, but I can't find out what I'm doing wrong.
RE: Check message by felipEx on 11-11-2006 at 05:05 PM
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.
RE: Check message by SnuZZer on 11-11-2006 at 05:23 PM
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 < "123" && Lille.charCodeAt > "96")
{
Alfabet[Lille.charCodeAt-97]++;
}
}
}
return Message;
}
RE: Check message by felipEx on 11-11-2006 at 05:51 PM
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
RE: Check message by SnuZZer on 11-11-2006 at 06:22 PM
Hi.
It works. Thanks!
|