frmHub.DoEventsForMe

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
Kenneth-Chile
Posts: 80
Joined: 2003-03-21 10:17
Location: Concepcion, Chile.

frmHub.DoEventsForMe

Post by Kenneth-Chile » 2003-11-08 12:17

what does it the instruction "frmHub.DoEventsForMe"?

I have this instructions in some scripts, in some custom commands, but in another ones, it doesn't appear. When does it use?
In Theory, there is no difference between Theory and Practice. In Practice, there is.

Snooze
Posts: 119
Joined: 2003-01-26 13:42
Location: Denmark
Contact:

Post by Snooze » 2003-11-08 12:32

You can find some VB scripting guides here..

http://mainserver2/snooze3/viewforum.php?f=12

Snooze
Posts: 119
Joined: 2003-01-26 13:42
Location: Denmark
Contact:

Post by Snooze » 2003-11-08 12:33

Opps ...
thats the local path and wont work.

check here

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

Re: frmHub.DoEventsForMe

Post by Sedulus » 2003-11-08 13:30

Kenneth-Chile wrote:what does the instruction "frmHub.DoEventsForMe" [do]?
it makes sure the command is executed

for instance if you send a message to a user and then disconnect him,
without the DoEvents after the message (before the disconnect), you cannot be sure that the message is sent before the user is disconnected.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-08 13:32

what does it the instruction "frmHub.DoEventsForMe"?
it tell to pass control to other program, this is for not tying the cpu to the script.
ex:when you don't want the script to freeze your puter while it is waiting for something.
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2003-11-08 13:37

Two different explanation, wonder which is the correct one?
Or is both correct?
:lol:

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-08 13:54

joakim_tosteberg wrote:Two different explanation, wonder which is the correct one?
Or is both correct?
:lol:
well Sedulus didnt post before i clic on reply...
the two explaination are the same, but view on a different side.
you cannot be sure that the message is sent before the user is disconnected.
your waitaing for something here don't you ? :wink:

if it's the same as VB.net DoEvent
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-11-08 17:37

i had to stop the searchkick of gadget cos my users were kicked with no reason sent

Code: Select all

  Else
    curUser.PrivateMessage cStr(Kicker),Kicker+" is kicking "+CurUser.sName+" because: "+Reason+" ("+sFileName+")"
    colUsers.SendChatToAll cStr(Kicker),Kicker+" is kicking "+CurUser.sName+" because: "+Reason+" ("+sFileName+")"
    colUsers.SendChatToAll "Hub-Security","The user "+CurUser.sName+" was kicked by "+Kicker+". IP: "+CurUser.IP
    frmHub.DoEventsForMe  
    curUser.Kick()
  End If
finally i had to delete the curUser.Kick() and kick them manually
dont know the reason

snooze, you are doing a good job in your forum, congratulations
Hi hi hoo

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-08 21:45

because missing --> () at the end of frmHub.DoEventsForMe() ?
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

TasMan
Posts: 196
Joined: 2003-01-03 08:31
Location: Canada
Contact:

Post by TasMan » 2003-11-08 22:36

DoEventsForMe simpy suspends executation (ie pauses thread)...it is needed before disconnecting a user because sending messages, etc need a bit of time to get sent out.
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-08 23:03

oh... :oops: ok, sorry.
i miss interpreted what i have read while learning VB.
it was about recursive behavior in a loop, that could stall windows(slow it down almost to a halt), not freeze it.
it can be use 2 different ways... thank for the info TasMan
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-08 23:07

it can be use 2 different ways...
:oops: same purpose induce a pause to give other things time.
i think it's begining to enter my wood head now. :lol:
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

Kenneth-Chile
Posts: 80
Joined: 2003-03-21 10:17
Location: Concepcion, Chile.

Post by Kenneth-Chile » 2003-11-09 08:53

Thanks to all :) :wink: :shock:
In Theory, there is no difference between Theory and Practice. In Practice, there is.

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

Post by Sedulus » 2003-11-09 09:14

I only stated what I found as a comment in a script once... so I will not vouch for its correctness

in any case, what google found on the DoEvents subject was the following:
a C implementation of DoEvents

Code: Select all

MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
    DispatchMessage( &msg );
}
now, I can only speculate about how VB and Jon's app work, but it wouldn't surprise me if the (chat) message sending to a user winds up in a (windows) message queue while the disconnect is immediate.
(the whole 'pause' argument does not sound like a real explanation)
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

TasMan
Posts: 196
Joined: 2003-01-03 08:31
Location: Canada
Contact:

Post by TasMan » 2003-11-09 11:04

VB's definition

Code: Select all

Function DoEvents() As Integer
    Member of VBA.Interaction
    Yields execution so that the operating system can process other events
Perhaps "pause" was the wrong word, but that is what I was trying to say =p. DoEventsForMe is just a wrapper function so that VBScripts can access the DoEvents function.
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....

TasMan
Posts: 196
Joined: 2003-01-03 08:31
Location: Canada
Contact:

Post by TasMan » 2003-11-09 11:05

Anyways you're right too....I would say the message DOES get queued. However you need to yield the threads execution for a moment so that the message gets sent before you disconnect the user.
Shadows Direct Connect Hub - Taking away the light from NMDCH, leaving only shadows.....

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-11-09 12:25

DoEvents is commonly used to ensure messages are sent, but it is not its only use, not even in DC scripting. Here is an example of DoEvents not related to message delivery :

Code: Select all

Sub DictClean(objDict)
Dim x, aClean
   aClean = objDict.Keys
   For x = 0 to objDict.Count-1
      If Not colUsers.Online(cstr(aClean(x))) Then objDict.Remove(aClean(x))
      If x Mod 75 = 0 Then frmHub.DoEventsForMe
   Next
End Sub
If the sub encounters a particularly large dictionary, it will take a break every 75 processed keys, and "give the hand" to the operating system, so it can process events that occured and have been queued during the time it took to process the 75 keys... Once these events are done, the "hand" goes back to the script for another 75 keys, etc etc.
That's what DoEvents is intended for : give a small coffee break to whichever script/program/thread called the DoEvents and take care of pending buisness that piled up in other places before resuming execution of the thread that called the DoEvents. Works great to have a NMDC hub send out these messages to users before they are kicked, but DoEvents was never designed specifically for NMDCH in general, or message handling in particular =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-09 21:42

so i was right in assuming that it pass control to other program(treads).
but still it is use to induce a pause and in some cases you also help other programs responsiveness.

is there any other way to use DoEventForMe, else then in your exemple?
to extend the time of the pause.

adding 2 or 3 DoEventForMe, one after the other?
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-11-09 23:34

While you can look at it as a pause, it is however not a "timed" pause for a fixed amount of (mili)seconds, but clearly a hold in the original thread to go "Do" the "Events" that pilled up while it was executing...

If you put 2 DoEvents in a row, the first DoEvents will hold/pause your script for a little while while the operating system processes everything that has been queued since it last had the hand... The second DoEvents will technically do the same and hold/pause the script again, but since the operating system just processed everything that was pending, your second DoEvents will have little to no effect.
If you get busy and caught in some RL stuff, and let your dishes pile for a day or two, it will take a lill bit to wash them all... But the next thing you do right after you're done washing the dishes is head back to the sink to do the dishes again, you'll only meet an empty sink with all the dishes already cleaned.. Need to do some cooking first before you can wash them again =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-10 00:16

:lol: understood

else than counting sheeps :wink: , what else can be done to extend the delays before other commands is execute?
like in InnerCity exemple, but without using to much cpu sicle or slowing the script to much.
i suspect that the more speedy the puter is, the more you get chance for problems, like InnerCity have, to happens.
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-11-10 03:53

what else can be done to extend the delays before other commands is execute?
You can use a timer (set it to 2 seconds, and keep it turned off), and put the 2 "batches" of commands in 2 different subs. Also declare a global variable at script level to keep track of the timer :

1) Launch the sub that will execute the first batch of commands, and at the end of the sub, turn the timer on.

2) In your timer sub, each time the sub gets executed, increment the global variable, and keep track of it. For example, if it reaches 5, it means 10 seconds elapsed (i.e. the timer event that happens every 2 seconds was launched 5 times).
When enough time has elapsed, turn the timer off, set your global variable to 0, and from the timer sub, launch the second sub :

3) The second sub, containing the second batch of commands will execute.

It's the method I used in the SDCH version of BlackJack/Pontoon, for example, to give users x seconds to join a new game.

Another method is to send your script on a big loop where it will repeat some dummy operation a million times. However, this won't work as well because different CPUs will take different times to process the loop, and make the pause vary a great deal from one computer to another. It will also tie up your CPU and a great deal of resources in general; which is something the timer method doesn't do (not to the same extent anyway).
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

InnerCity
Posts: 105
Joined: 2003-05-17 00:35

Post by InnerCity » 2003-11-10 05:19

i've got a hub where music and films are forbidden, searchkick is implemented in general bot .241, but after one or two days running the hub (not refreshing/restarting the computer) it let users connect with shareds plenty full of music, i decided to separate these two scripts, deleted searchkick inside general bot and started running separated, then searchkick works fine now but...the messages are not sent before users are kicked...this happens in my AMD1.800XP, but when the hub runs in the 500 Mhz of a friend also some of the basic general bot messages are not sent (not enough slots and similar). i receive mails of users asking why they cant connect to the hub (as they dont know the reason of disconnect they dont know what detail of their configuration need to change)...the question of the messages is very important,i think, dont mind if script works slow, the important is if script work fine, so i would like to have a basic-timer-function to be called before some instructions
all scripts really work when the user connect (general bot check the configuration, searchkick look for bad files, bulletin data shows its welcome message, the onjoin...), my friend, the one that have the 500 Mhz, says: "when a new user connects my CPU usage is 40%"...O_o, so there must be a way of avoid a scripts-bottleneck that results in a bad working of all of them

and was thinking if changing this "tmrScriptTimer.Interval=60000" to a higher value...¿?¿?¿ what is the utility of this instruction?
Hi hi hoo

TheNOP
Posts: 275
Joined: 2003-07-07 21:41
Location: Quebec

Post by TheNOP » 2003-11-10 10:00

i will check BlackJack/Pontoon code.

thanks ButterflySoul
TheNOP

Have you read the FAQ?
Or the sticky ? It might give you idea.

Locked