Although %var content may be too long for many commands such as /write, /echo and /set, it's still possible to handle it with identifiers like $right, $left, $mid, $pos, $wrap and - $regex.
It's possible to force wrapping by using a loop like -
var %i = 1
while $mid(%data,%i,400) {
search.in $ifmatch
inc %i 400
}
but in this way some of the urls may cut somewhere in the 400th (or 800th) char, and search.in will not be able to handle them.
I think $regex is a fair solution for this. Here's a sample script:
alias g sockopen g www.google.com 80 | sockmark g $1-
on *:sockopen:g:{
sockwrite -tn g GET /search?as_q= $+ $sock(g).mark $+ &num=100 HTTP/1.1
sockwrite -tn g Host: www.google.com
sockwrite -tn g
}
on *:sockread:g:{
var %s
sockread %s
if $regex(%s,/<p class=g><a href=(\S+)>/gi) {
var %i = 1
while $regml(%i) {
echo -s $ifmatch
inc %i
}
}
}
Try /g peace, for example, and check the status window.
As you can see, the $regex pattern is:
/<p class=g><a href=(\S+)>/giThe html parts is used for identifying url results, where \S+ matches the url itself and enclosed by quotes to tell mIRC we want to save them for later reference by $regml(N).
For more information check the
Regex tutorial from mircscripts.org, and
man.txt for further reference.
You can also get some ideas from other scripters who made
google scripts.