What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with cancelling msgplus timer

Pages: (2): « First « 1 [ 2 ] Last »
Help with cancelling msgplus timer
Author: Message:
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Help with cancelling msgplus timer
what is coming up in the debugger? we really need that information to be able to help you out ;)
03-11-2007 08:49 PM
Profile PM Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
Joined: Nov 2006
O.P. RE: Help with cancelling msgplus timer
Okay, I ran the debugger with this:
quote:
var ChatWnds = new Array();
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if(Message == "!s"){
ChatWnd.SendMessage("/vc 15");
ChatWnds[ChatWnds.length-1] = ChatWnd;
MsgPlus.AddTimer("Delay1"+ChatWnds.length-1, 15300);
else if(Message == "!q"){
MsgPlus.CancelTimer("Delay1"+ChatWnds.length-1);

}
}

function OnEvent_Timer(TimerId){
switch(TimerId.substr(0,6)){
case "Delay1":
ChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
MsgPlus.AddTimer("Delay2"+[TimerId.substr(6)], 15200);
break;
case "Delay2":
ChatWnds[TimerId.substr(6)].SendMessage("/vc 15");
And the debugger displayed:
quote:
Script has been stopped
Error: Syntax error.
       Line: 7. Code: -2146827286.
Line 7 is else if(Message == "!q"){ in the scripting window. 

Next, I removed else from that line, then the debugger displayed:
quote:
Error: Expected '}'.
       Line: 58. Code: -2146827279.
The actual script is longer, so this line is past the case "Delay 10" call.  So I placed an "}" there and it says the script is loaded and ready.

But now, it won't send anything past the first delay, regardless of whether "!q" is sent or not.


This post was edited on 03-11-2007 at 09:43 PM by Rizu.
03-11-2007 09:30 PM
Profile E-Mail PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Help with cancelling msgplus timer
That's because you forgot to close the first if statement like the debugger says, you need a }
[Image: 1-0.png]
             
03-11-2007 09:56 PM
Profile PM Web Find Quote Report
Rizu
New Member
*

Avatar

Posts: 12
– / Female / –
Joined: Nov 2006
O.P. RE: Help with cancelling msgplus timer
Now, the script functions, but it does not work the way I want it to.  It will just stop the timer after the first delay, regardless of whether "!q" is received or not.

When the script is running properly, I type !s, and the debugger window reads that the function ChatWndReceiveMessage is called, and the voice clip records and sends.  After it has been sent, the debugger reads that the Timer has been called as the other voice clip records and so on.

This does not happen when I include the CancelTimer syntax.  So, perhaps I'll need to stop the subsequent Timer events from happening.

03-11-2007 10:02 PM
Profile E-Mail PM Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: Help with cancelling msgplus timer
code:
"Delay1"+ChatWnds.length-1
This is not a valid string. "Delay1" is a string and ChatWnds.length is a number, so the plus operator (+) joins them together as a new string object. The -1 is supposed to subtract 1 from a number object, but as "Delay1"+ChatWnds.length is a string, the result is you get a messed up timer ID.

Your original script was correct in putting brackets there:
code:
"Delay1"+[ChatWnds.length-1]
This way, the number is calculated first, then appended to "Delay1". The reason why it probably didn't work was because of the end parentheses for the first if statement.


Also, may I suggest naming your timers something like "ClipxChatx". Then a simple regular expression can be used to handle your timers:
code:
function OnEvent_Timer(TimerId) {
    if(/^Clip(\d+)Chat(\d+)$/.test(TimerId)) {
        var Clip = RegExp.$1;
        var Chat = RegExp.$2;
        aChatWnds[Chat].SendMessage("/vc 15");
        if(Clip < 10) MsgPlus.AddTimer("Clip" + (Clip * 1 + 1) + "Chat" + Chat, 15200);
    }
}
Of course, your method is still valid.

This post was edited on 03-12-2007 at 12:48 AM by phalanxii.
03-11-2007 11:36 PM
Profile PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: Help with cancelling msgplus timer
quote:
Originally posted by phalanxii
   
code:
"Delay1"+ChatWnds.length-1

This is not a valid string. "Delay1" is a string and ChatWnds.length is a number, so the plus operator (+) joins them together as a new string object. The -1 is supposed to subtract 1 from a number object, but as "Delay1"+ChatWnds.length is a string, the result is you get a messed up timer ID.

Your original script was correct in putting brackets there:

 
code:
"Delay1"+[ChatWnds.length-1]

This way, the number is calculated first, then appended to "Delay1". The reason why it probably didn't work was because of the end parentheses for the first if statement.

no... if you want to make sure it is calculated first use:
code:
"Delay1"+(ChatWnds.length-1)
but even without it probably works correctly...
03-12-2007 12:26 PM
Profile E-Mail PM Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: RE: Help with cancelling msgplus timer
quote:
Originally posted by foaly
no... if you want to make sure it is calculated first use:
code:
"Delay1"+(ChatWnds.length-1)
but even without it probably works correctly...

The syntax in the original script still works. Take for example:
code:
var aChatWnds = [1, 2, 3];
Debug.Trace("Delay1"+[aChatWnds.length-1]);
The debug logs "Delay12", as it should be. Sure, your way with round brackets works too.

However, it does not work correctly without it! The same code, without the brackets:
code:
var aChatWnds = [1, 2, 3];
Debug.Trace("Delay1"+aChatWnds.length-1);
This time, the debug reads "-1.#IND"...
03-13-2007 08:19 AM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« 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