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?

Pages: (2): « First « 1 [ 2 ] Last »
2 votes - 3 average   So is it impossible to make a Sleep() function?
Author: Message:
ben_b
Junior Member
**

Avatar

Posts: 33
– / Male / –
Joined: Jul 2003
RE: So is it impossible to make a Sleep() function?
So how could I make the following sleep for 5 seconds at the location indicated...

code:
function OnEvent_ChatWndSendMessage(Wnd,Msg) {
    if(Msg == "^toast") {
   
        var x = 0;
   
        do
            {
                Messenger.MyStatus = 2;
                Messenger.MyStatus = 3;
                x = x+1
                //Sleep here
            }
        while (x < 3);
       
    return "";
    }
}
07-14-2006 08:18 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: So is it impossible to make a Sleep() function?
I suggest you simply don't...


quote:
Originally posted by CookieRevised
Each time I needed a sleep() in programs I made, there were always better ways to do this.

What I mean is, you can almost always make a program without the use of a sleep() or the likes. The use of sleep() is almost always not needed at all and often is the result of a bad made routine... at least that's my experience of it.

(there are some uses for it of course, but they are rare)

In the shown routine you could easly make that without the use of a dirty sleep() function. All you need in your case is to set a timer in the "IF (Msg==blah)" function and when that timer is triggered perform the status changes once more (two times). It would be much more elegant (and doesn't halt everything else).

;)
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-14-2006 09:51 AM
Profile PM Find Quote Report
ben_b
Junior Member
**

Avatar

Posts: 33
– / Male / –
Joined: Jul 2003
RE: So is it impossible to make a Sleep() function?
Exactly... I haven't been able to get the timers to work so I was looking for a little more help on how to make the timers work... here's my current code...

code:
//Check for /command
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage) {
    if(sMessage.charAt(0) == "/"){
        return parseCommands(sMessage,ChatWnd);
    }
    else{
        return sMessage;
    }
}

//Add the /command in command list
function OnGetScriptCommands(){
    var commands = '<ScriptCommands>';
        commands+='<Command>';
            commands+='<Name>toastspammer</Name>';
            commands+='<Description>Appear Offline and then back Online</Description>';
            commands+='<Parameters/>';
        commands+='</Command>';
    commands+='</ScriptCommands>';
    return commands;
}

//Parse commands
function parseCommands(sMessage,iOriginWnd) {   
    var x = 0;
   
    do
        {
            Messenger.MyStatus = 2;
            Messenger.MyStatus = 3;
            x = x+1
            //Sleep here
        }
    while (x < 3); //Number of times to sign on and off
                 //NOTICE: Messenger can't handle very many without
                 //          slowing down or possibly crashing, unless
                 //          the timer is enabled so they don't all occur
                 //          at the same time.
       
    return "";
}
07-14-2006 09:55 AM
Profile E-Mail PM Find Quote Report
sbegouin
Junior Member
**


Posts: 25
Joined: Sep 2005
RE: So is it impossible to make a Sleep() function?
You can just use this DLL (see attachment) :

code:
    Interop.Call(MsgPlus.ScriptFilesPath+'\\Wait.dll', "Attente", 1000); // Wait 1000 ms
    Interop.FreeDLL(MsgPlus.ScriptFilesPath+'\\Wait.dll');

.zip File Attachment: Wait.zip (7.84 KB)
This file has been downloaded 241 time(s).
07-24-2006 10:27 PM
Profile E-Mail PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
O.P. RE: RE: So is it impossible to make a Sleep() function?
quote:
Originally posted by sbegouin
You can just use this DLL (see attachment) :

code:
    Interop.Call(MsgPlus.ScriptFilesPath+'\\Wait.dll', "Attente", 1000); // Wait 1000 ms
    Interop.FreeDLL(MsgPlus.ScriptFilesPath+'\\Wait.dll');


That just calls Sleep() which you can do with Interop.Call directly too. And it's not multithreaded, so it'll freeze WLM.
The previous sentence is false. The following sentence is true.
07-25-2006 11:18 AM
Profile PM Find Quote Report
sbegouin
Junior Member
**


Posts: 25
Joined: Sep 2005
RE: So is it impossible to make a Sleep() function?
This method doesn't freeze the processor (usage is at 0%) :), but during this, you can't do anything with WLM. :(

This post was edited on 07-25-2006 at 06:13 PM by sbegouin.
07-25-2006 06:10 PM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: RE: RE: So is it impossible to make a Sleep() function?
quote:
Originally posted by segosa
That just calls Sleep() which you can do with Interop.Call directly too. And it's not multithreaded, so it'll freeze WLM.

He never said it froze the processor.
07-25-2006 06:55 PM
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