mIRC Home    About    Download    Register    News    Help

Topic Options
#186571 - 23/09/07 10:31 PM sockread from the helpfile
pouncer Offline
Hoopy frood

Registered: 02/10/05
Posts: 827
Code:
Example:

This example shows you how you should process a sockread event. The socket has already been opened and has received information, so the sockread event is triggered. The socket name is testing. There is an explanation of each step below the sample script.


on 1:sockread:testing:{

if ($sockerr > 0) return

:nextread

sockread %temp

if ($sockbr == 0) return

if (%temp == $null) %temp = -

echo 4 %temp

goto nextread

}


thats from the mIRC help saying thats how it should be processed, but i never see sockread events like this using goto and stuff. is this an outdated help file or something?

Top
#186573 - 23/09/07 10:33 PM Re: sockread from the helpfile [Re: pouncer]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
That should work, but yes. Most people use a 'while' loop instead of the older 'goto' methods.

Top
#186574 - 23/09/07 10:38 PM Re: sockread from the helpfile [Re: Bekar]
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
And then there's some that don't use loops, like myself.

Code:
On *:Sockread:sock: {
  var %tmp
  sockread %tmp
  if (something isin %tmp) ..
}

Top
#186581 - 23/09/07 10:57 PM Re: sockread from the helpfile [Re: SladeKraven]
pouncer Offline
Hoopy frood

Registered: 02/10/05
Posts: 827
yep thats what i do slade except i also tokenize after the sockread %tmp so i can check $1 $2 $3 etc

i dont understand why loops and stuff are needed at all

Top
#186583 - 23/09/07 11:00 PM Re: sockread from the helpfile [Re: pouncer]
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
I remember a discussion about goto loops and such in the On Sockread event but I can't seem to find it. They probably were needed back then, otherwise Khaled probably wouldn't have put that in the sockread event in the first place. But don't quote me on that though. smile

Top
#186587 - 23/09/07 11:44 PM Re: sockread from the helpfile [Re: SladeKraven]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
I think the point to using goto or while is if the line is continued on the next line or is too big for tokenize. I wasn;t very clear on that though. I wish I knew because I've had issues where the line gets broken up into two lines occasionally.

This happened to be with a room list. Sometimes the topic is so long so the user count and language arent found on that line but the next line. I thought using this goto or while loop would allow me to consider it the same line, but I wasn't very sure.

Top
#186592 - 24/09/07 12:45 AM Re: sockread from the helpfile [Re: DJ_Sol]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
When pulling from a socket, the packet size is how much data is read by the 'sockread'.

Using a while/goto loop will process all the queued data in the one event trigger, as against re-triggering the event over-and-over.

During the re-triggering of the event, it's possible (but doubtful) that another even tcould trigger, thus changing the environment scope..

But I guess it all depends on how you've written your event.

Top