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?
That should work, but yes. Most people use a 'while' loop instead of the older 'goto' methods.
And then there's some that don't use loops, like myself.
On *:Sockread:sock: {
var %tmp
sockread %tmp
if (something isin %tmp) ..
}
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
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.
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.
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.