Im really loving binvars, this is roughly what I do.
Binvars handle the line byte by byte, or character by character. You can change it to a text result with the $bvar(&var,N).text where the N stands for the byte number.
1 is the 1st character or byte. 2 is the second character or byte. 32 is the 32nd character in the line and so on. So if I say $bvar(&var,48-).text, it will return everything from character 48 on in plain text format. (Read the mirc help file for more information.)
Lets say Im searching for an email address in a very long line.
I first have the sockread echo to a window so I can find what to look for.
echo -a $bvar(&var,1-).textLet's say I want to retrieve the "mailto" address from a page. First I find the email address in the code.
<a class="no-textdecoration-white" href="mailto:webmaster@email.com">Contact Webmaster</a> -
Then I look for something before the address that only exists in this one place and nowhere else on the whole page. Let;s say I got lucky and "mailto:" only exists on this one line.
As starbucks Mafia pointed out, you sockread -f to a &binvar. We will name it &var.
sockread -f &var
Then use $bfind to find "mailto:".
if ($bfind(&var,1-,mailto:)) {This starts at character 1 and searches everything after. (1-)
;It's found mailto: and now gives me the byte number for the first character in my search string. "m" is the 41st character.
<a class="no-textdecoration-white" href="m
So now I know that $bvar(&var,41).text == m. I also know that there are 7 characters in mailto: so 41 + 7 is the first character of the email address. I set this number (41 + 7) as a local variable and then I search for the end of the email address.
As you can see, mailto:webmaster@email.com" , it has a " at the end of it. So what I do is start my search from the beginning of the email address and search for the next " and set the number as the 2nd local variable.
(Binvars allow you to search for ascii characters or plain text characters.)
So this is how I do it.
if ($bfind(&var,1-,mailto:)) {
var %em_1 = $calc($ifmatch + 7), %em_2 = $bfind(&var,%em_1,")
echo -a Email Address is $bvar(&var,%em_1,%em_2).text !
}
Ok so now I know the last number of the email address. (%em_2)
If I need to search for anything else in this line I will start my search from this number doing it the same way.
This may not be the best way of using binvars but this is how I figured it out. I hope it makes sense. mIRC help file has a lot to say about using binvars and the identifiers that help you.