What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » So is it impossible to make a Sleep() function?

2 votes - 3 average   So is it impossible to make a Sleep() function?
Author: Message:
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: So is it impossible to make a Sleep() function?
why would you ever want to while loop to pause your code :( just pass a function and get the function which handles the timer to call it when it is up and you can use closures to pass variables

eg

code:
var callback;
function myCode(arg1){
    //do stuff
   
    //oh noes now i need to sleep to wait for a value
   
    //function to call when timer is up
   
    function returnCallback(arg1){
        function callback(arg){
            return arg1 * arg;
        }
    return callback;
    }
    callback = returnCallback(5);
    MsgPlus.AddTimer("MyTimer",5000);
   
}



function OnEvent_Timer(TimerId){
    if(TimerId == "MyTimer"){
    //it should show the result of 5*5
    Debug.Trace(callback(5));
    }
}





more on javascript closures here
http://jibbering.com/faq/faq_notes/closures.html

This post was edited on 06-27-2006 at 02:39 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
06-27-2006 02:36 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
So is it impossible to make a Sleep() function? - by segosa on 06-26-2006 at 10:38 PM
RE: So is it impossible to make a Sleep() function? - by mathieumg on 06-26-2006 at 11:07 PM
RE: So is it impossible to make a Sleep() function? - by segosa on 06-26-2006 at 11:13 PM
RE: So is it impossible to make a Sleep() function? - by CookieRevised on 06-26-2006 at 11:48 PM
RE: So is it impossible to make a Sleep() function? - by Riveck on 06-27-2006 at 12:14 AM
RE: RE: So is it impossible to make a Sleep() function? - by b0rna on 06-27-2006 at 12:42 AM
RE: So is it impossible to make a Sleep() function? - by TheBlasphemer on 06-27-2006 at 01:16 AM
RE: RE: So is it impossible to make a Sleep() function? - by segosa on 06-27-2006 at 07:11 AM
RE: So is it impossible to make a Sleep() function? - by b0rna on 06-27-2006 at 01:28 AM
RE: So is it impossible to make a Sleep() function? - by -dt- on 06-27-2006 at 02:36 AM
RE: So is it impossible to make a Sleep() function? - by ben_b on 07-14-2006 at 08:18 AM
RE: So is it impossible to make a Sleep() function? - by CookieRevised on 07-14-2006 at 09:51 AM
RE: So is it impossible to make a Sleep() function? - by ben_b on 07-14-2006 at 09:55 AM
RE: So is it impossible to make a Sleep() function? - by sbegouin on 07-24-2006 at 10:27 PM
RE: RE: So is it impossible to make a Sleep() function? - by segosa on 07-25-2006 at 11:18 AM
RE: RE: RE: So is it impossible to make a Sleep() function? - by deAd on 07-25-2006 at 06:55 PM
RE: So is it impossible to make a Sleep() function? - by sbegouin on 07-25-2006 at 06:10 PM


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