mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I am using a socket to read the html code of the room list.
Because some lines are too long to tokenize I am using Binary Variables. I have used them succesfully in the past.

Quote:
<tr class="rmlist_r2">
<td valign=middle align=right> </td><td valign=middle align=left nowrap><a href="chatui.aspx?rm=%25%23Srangerchat" class="rmlist">Srangerchat</a></td><td> </td><td style="text-align: right;">1</td><td>English</td>
</tr>


This is what I want to get the room name, topic, room count and language from.

Code:
sockread -gn &brL
if ($bfind(&brL, 1, "rmlist">)) {
;Retrieve Channel Name
var %cx = $calc($ifmatch + 9), %cb = $bfind(&brL, %cx, </a>), %f = $calc(%cb - %cx)

channel name is $bvar(&brL,%cx,%f).text

;Retrieve Topic
var %ct = $calc($bfind(&brL, %cb, <td>) + 4), %ctx = $bfind(&brL, %ct, ;</td>), %tt = $calc(%ctx - %ct)

topic is $bvar(&brL,%ct,%tt).text

Now my difficulty lies in getting the language and count.
I start from the end of topic and filter html code out of the rest and it becomes 10English, for instance.

$bvar(&brL,%ctx $+ -).text


95% of the time it works great! But sometimes, instead of the count and language I get ...

valign=middle align=right> </td><td valign=middle align=left nowrap><a href="chatui.a

Which is in the beginning of the line. I just dont get it!

I need some help.

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
My guess is that your loop retrieving the binary variable gets up to x bytes with one sockread, and it just so happens to be the break in the text.

You might want to write the entire socket conversation to a temporary file, then parse it once it's complete.

Joined: Jul 2006
Posts: 4,155
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,155
I noticed that you used sockread -gn, guess it's a typo because -g doesn't exists.you certainly want to use sockread -fn.
Maybe this typo isn't the problem, so what you can do is to make a while on $sockbr, to be sure to catch the whole data (there is an exemple in mirc help file, /help /sockread) and try what Bekar said smile

Last edited by Wims; 06/09/07 05:46 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard