mIRC Home    About    Download    Register    News    Help

Topic Options
#139046 - 09/01/06 11:10 PM reading comma seperated text
drdevil Offline
Mostly harmless

Registered: 09/01/06
Posts: 1
is it possible to read in a txt file a with a comma (,) seperated text like :

Our members have made a total of <b>22,708</b> posts<br

i want to read the 22,708 by using this code:

on *:TEXT:!forumstats*:*:{ if ($1) { getpdm $iif(#,#,$nick) $2 } }
alias getpdm { .remove p.txt | sockopen pdm dc-styles.com 80 | sockmark pdm $1- }
on *:sockopen:pdm:{ sockwrite -n pdm GET http://www.dc-styles.com/forums/index.php | sockwrite -n pdm Accept: */* | sockwrite -n pdm Host: dc-styles.com:80 | sockwrite -n pdm Proxy-Connection: Keep-Alive | sockwrite -n pdm $crlf }
on *:sockread:pdm:{ if ($sockerr) { return }
:read
sockread &pvar | bwrite p.txt -1 -1 &pvar | if ($sockbr) { goto read }
}
on *:sockclose:pdm:{
tokenize 32 $sock($sockname).mark
if ($regex(xx,$read(p.txt, w,$+(*,Our members have made a,*)),total of <b>([[:digit:]]+))) { msg $1 Total Posts: $regml(xx,1) }
else { msg $1 No matched found }
}

but the result is: Total Posts: 22 instead of 22,708

someone plz help me out! how do i make it it shows the full number or convert the , to a .

DrDevil

Top
#139047 - 09/01/06 11:41 PM Re: reading comma seperated text
FiberOPtics Offline
Hoopy frood

Registered: 05/02/04
Posts: 2019
Loc: Leuven, Belgium
1) Get $download()

2)
Code:
alias dcstyles {
  if ($download(dcstyles.txt,GET,http://www.dc-styles.com/forums/index.php,3,text)) {
    if ($read(dcstyles.txt,nr,/made a total of &lt;b&gt;(.*?)&lt;\/b&gt; posts/)) return $regml(1)
  }
  else return Error retrieving source.
}


To use you call it like: $dcstyles

Example: //echo -a Total: $dcstyles

Since this result isn't going to change every minute, you should store result in a global var, and retrieve the value of the variable, and only update every 15 minutes or so.

Note the alias dcstyles will pause the script until the result is retrieved, without freezing mIRC. If you want this to be triggered on a channel do it like this:

on *:text:!total:#channel: .timer 1 0 msg # Total: $!dcstyles

The timer is essential, so that $dcstyles doesn't pause your on text event.
_________________________
Gone.

Top