mIRC Homepage
Posted By: GBX some parts cut out when sockreading - 24/03/03 02:50 AM
i have a really weird prob
i do a normal sockread, only echoing der variable i read in and it returns the following:
Code:
<td colspan="1" nowrap><select class='mini' name='GameTypeSelect'><option value="XGame.xBombingRun">Bombing Run</option><option value="XGame.xCTFGame">Capture the Flag</option><option value="XGame.xDeathMatch" selected>DeathMatch</option><option value="XGame.xDoubleDom">Double Domination</option><option value="Excessive.ExcessiveBR">Excessive Bombing Run</option><option value="Excessive.ExcessiveCTF">Excessive Capture The Flag</option><option value="Excessive.ExcessiveDM">Excessive Death Match</option><option value="Excessive.ExcessiveDD">Excessive Double Domination</option><option value="Excessive.ExcessiveTDM">Excessive Team Death Match</option><option value="SkaarjPack.Invasion">Invasion</option><option value="BonusPack.xLastManStandingGame">Last Man Standing</option><option value="BonusPack.xMutantGame">Mutant</option><option value="Rocketeer084b.RocketeerGame">Rocketeer 2003</option>[color:red]<option value="XGame.xTe
thmatch</option>[/color]</select>

instead of:
Code:
... [color:red]<option value="XGame.xTeamGame" selected>Team Deathmatch</option>[/color] ...

i examined the packages i received, but there was everything ok
so mirc cuts out some characters and put a $crlf instead
i really cant figure out why
Posted By: codemastr Re: some parts cut out when sockreading - 24/03/03 03:48 AM
Did you remember that you must call sockread from within a loop? Meaning, a single sockread is not guaranteed to read all the data.

Something like: (taken from the helpfile but modified to use local variables and a while() loop)
Code:
on 1:sockread:testing:{
   var %temp
   if ($sockerr > 0) 
      return
   while ($true) {
      sockread %temp
      if ($sockbr == 0) 
         break
      if (%temp == $null) 
         break
      echo %temp
   }
}
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 09:36 AM
yes, i know, but i didnt want to post the whole html file
the event is triggered several times before and after this line
to be sure, i also tested your solution, but it didnt help
it strongly seems to me that it is a mirc bug
Posted By: ppslim Re: some parts cut out when sockreading - 24/03/03 12:09 PM
This is not a mIRC bug.

mIRC is limited in the length it will store in a variable.

As such, mIRC will fill it up, and as such, it wraps at the point where you claim the bug is produced.

It is up to the script (you) to deal with search, replace, dis/asembly of the incoming text.
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 12:21 PM
i couldnt find a note describing a limitation on variables and this is not the first time this happened
the last time the line was only about 10 chars long
and if it is a limitation, how can i workaround it?
what else can i do than letting sockread write into a variable?
do i have to use a binvar which is really not very useful at this point?
Posted By: ppslim Re: some parts cut out when sockreading - 24/03/03 12:26 PM
Parse the incoming text, and work out once the string is complete.

Binvars will not help in any way, when reading this sort of text.
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 12:32 PM
ok, and where can i get the missing 25 characters?
Posted By: ppslim Re: some parts cut out when sockreading - 24/03/03 02:58 PM
Use the "numbytes" parameter to limit the amount of bytes read from the socket

EG, use 20

THis will prevent over-filling of variables.
Posted By: codemastr Re: some parts cut out when sockreading - 24/03/03 04:35 PM
I would suggest you take a look at binary variables.
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 05:37 PM
numbytes only works with binvars
i know how to use binvars, but that would be a very ugly solution
Posted By: codemastr Re: some parts cut out when sockreading - 24/03/03 05:45 PM
You should really always use binvars when reading from a socket. So it wouldn't be an ugly solution, it would be a correct solution.
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 06:35 PM
correct solutions are only seldom the best solution
ok, now i use binvars and it works, but the the size of the script is doubled and it is much more harder to read it
not what i really wanted to
but thx anyway

seems to be really a limitation to string variables
should be noted in the help file
Posted By: codemastr Re: some parts cut out when sockreading - 24/03/03 08:10 PM
Ok then fine, come up with some other hack that will barely work and will provide confusion code. Me? Well I'd rather use correct well structured code that works in all circumstances. For example, mIRC strips a trailinf $crlf, well what if this were inside a tag say <textarea> where a $crlf is important? Using regular variables, your data is now invalid and corrupt, using binary variables it continues to work perfectly.
Posted By: GBX Re: some parts cut out when sockreading - 24/03/03 08:58 PM
i didnt say that vars are always better than binvars
but in my case it is, because the code structure became worse
btw the line doesnt contain a $crlf
so the only problem was the string limitation i didnt know before
same problem when reading over 4k data into a binvar, except that mirc cuts out some chars from the string

but now it works, so thx to all for help
Posted By: codemastr Re: some parts cut out when sockreading - 25/03/03 12:29 AM
But the 4k limit on binvars is not a hardlimit, you can easily change it using the "numbytes" parameter of sockread.
Posted By: KiTiK Re: some parts cut out when sockreading - 25/03/03 01:40 AM
I can say that this is not a long msg trouble.
If the string is too long the script which echoes the string will be halted with this error msg:
-
* String too long: Somthing
-
It's not a bug, mirc returns what the net (or the socket) sends it!
I hope I was clear,
ZaC a.k.a. KiTiK
Posted By: GBX Re: some parts cut out when sockreading - 25/03/03 11:59 AM
this error msg occurs only if i sockread into a binvar und then copy the content to a string var
but when you directly sockread into a var, no error msg comes up, only some chars missing, nothing else
and i proved with a sniffer what exactly was sent to mirc
i think the sockread command could be optimized to trigger an error msg if this happens or just dont cuts out chars anymore
© mIRC Discussion Forums