AddTimer makes msn crash - 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: AddTimer makes msn crash (/showthread.php?tid=64725) AddTimer makes msn crash by Dauntless on 08-10-2006 at 12:08 AM
Hi, code:(I know this code could be A LOT shorter, but i'm trying to do it as well-structured as possible). I think the problem is that every time a message is sent, the OnEvent_ChatWndSendMessage is called (so not just, when I type something, but also when msn sends out a message (window.sendMessage(). I thought this would be fixed by the 'counting' var but appearantly, it is not. I also created an extra variable 'currentCW' because I didn't know how to keep track of the current window, while going from AddTimer to onEvent_Timer And lastly: Does type-casting exist in JScript? 'cause now, i have this: sendMessage(counter); but sendMessage requires a string, not a number. Is it automaticly being casted? (And is there a way to do it manually ?) All help is welcome . RE: AddTimer makes msn crash by Silentdragon on 08-10-2006 at 12:36 AM
1. Jscript automatically converts between types. code:That returns nothing making your script not work. Return msg. code:One second timer. code:Add code:Timers run once then go away, you need to make it run each time you need it to. And yes it could be greatly simplified. 1278 / 479 RE: RE: AddTimer makes msn crash by Dauntless on 08-10-2006 at 12:49 AM
quote:If I would return msg, you would see "/countdown"... And I dont want it to display the command! quote:I fixed this and now he does display 'Happy new year' after 5 seconds... But I also want him to display '5', '4', '3', ...code:One second timer. And do you know the answer to my other questions ? RE: AddTimer makes msn crash by cloudhunter on 08-10-2006 at 01:09 AM
Your code looks needlessly complex, and the fact that OnEvent_ChatWndSendMessage is called evertime a message is sent isn't a problem... And your check command function isn't really needed either. you could just do a simple code: I would tell you more but your code confuses me... Cloudy RE: AddTimer makes msn crash by Silentdragon on 08-10-2006 at 03:17 AM
quote: If you read your code you'd understand that because you don't do that, it causes your whole code to fail. Also doing that won't make the command show, as it returns the message if it is counting. code:Works, and is simplified. RE: RE: AddTimer makes msn crash by Dauntless on 08-10-2006 at 07:45 AM
quote:I wrote this myself! I just only thought about the first time the event is triggerd (when you type /countdown). Now, it's really not that complex... I mean, how complex can 100 lines of basic JScript be... The flow of the program: -receive message -check if its a command (checkCommand()) -if its a command, what command? (getCommand()) -switch between the known commands (switch statement) -if the command is 'countdown', call 'countDown()' -add a timer and send a message (sendMessage) Since JScript doesnt support propper OO, I can't put this in nice, structured classes . And from your code, i take it that type conversion is done automaticly ? RE: AddTimer makes msn crash by Silentdragon on 08-10-2006 at 07:51 AM
Yes, it converts automatically. Although adding strings to integers and such is somewhat weird, but its understandable. RE: AddTimer makes msn crash by RaceProUK on 08-10-2006 at 08:43 AM
quote:Certainly more complex than 24. If two pieces of code do the same thing, and one is shorter, use that one. Shorter is often simpler. quote:The only thing that JScript doesn't support is inheritance, which also removes polymorphism and abstraction. Both of which aren't necessary in scripting really. There are plenty of other OO features though: a function declaration can actually define a class, and using the 'prototype' property, objects both built-in and custom can be extended. quote:JScript is a weakly-typed language, which means that all datatypes are implicit, and all possible conversions are performed automatically. RE: RE: AddTimer makes msn crash by Dauntless on 08-10-2006 at 08:49 AM
quote:Hmm, I hate that kind of OO... I don't know if you know ActionScript, but it's a lot like JScript. v1.0 supports OO through prototypes and V2.0 supports true OO through custom made classes. RE: AddTimer makes msn crash by -dt- on 08-10-2006 at 08:56 AM
you can typecast stuff with code: code: there are others like Boolean and RegExp RE: AddTimer makes msn crash by Dauntless on 08-10-2006 at 08:57 AM Thx dt . RE: AddTimer makes msn crash by -dt- on 08-10-2006 at 09:05 AM
also Flash uses SpiderMonkey to provide its javascript (which they call ActionScript) code: RE: RE: AddTimer makes msn crash by Dauntless on 08-10-2006 at 09:10 AM
You are right that it actually only supports prototype based classes, BUT: In AS 2.0, you CAN write classes. But when you compile your movie, the compiler transforms your AS 2.0 class into AS 1.0 prototype based OO. code: |