mIRC Homepage
Posted By: SpaceBoy filtering ASCII - 03/10/03 09:19 AM
Hi

I have some scripts that pull news headlines from websites to display in my channel - however, sometimes when a character appears in a headline, it displays the value of that character, instead of the character itself - example:

BA's Marshall rules out near-term tie-up with Iberia on regulatory grounds

should read:
BA's Marshall rules out near-term tie-up with Iberia on regulatory grounds

Any easy way around this?
Thanks!
Posted By: theRat Re: filtering ASCII - 03/10/03 11:32 AM
I think that this can be achieved pretty easily with regexp & $chr as ' is ' and its ascii is 39...
Posted By: Iori Re: filtering ASCII - 03/10/03 01:09 PM
Code:
alias spchrs {
  var %a = $1-
  while $regex(%a,/(&#\d*;)/) { var %a = $replace(%a,$regml(1),$chr($remove($regml(1),&#,;))) }
  return %a
}
Code:
  var %a = BA's Marshall rules out near-term tie-up with Iberia on regulatory grounds
  echo -a $spchrs(%a)
as this is from a sockread it most likely already is a %var. smile
Posted By: cold Re: filtering ASCII - 03/10/03 01:15 PM
Edited - Iori has posted a far better method smile
Posted By: SpaceBoy Re: filtering ASCII - 04/10/03 02:47 AM
thank you all. Iori - here's my code (minus the socket stuff)
if you could possibly assist me as to where to insert your code, I'd be gratefull...!

on 1:sockread:info:{
if ($sockerr > 0) return
:nextread
sockread %newstemp
if ($sockbr == 0) return
if (%newstemp == $null) %newstemp = -
if (<td nowrap valign=top isin %newstemp) {
set %infotxt $remove($gettok(%newstemp,5,62),</td)
write -l4 scripts/news.txt %infotxt - Infotec
sockclose info
set %info $read(scripts\news.txt,nw,*- Infotec*)
if (%info == $null) return
if (%info.last != %info) {
set %info.last %info {
msg #NewsRoom 0,7»1,15 $asctime($calc( $gmt + 7200 ),HH:nn)) $+ CET > %info 7,7 0,14 url .itec 
}
}
}
}

thank you again.
Posted By: Iori Re: filtering ASCII - 06/10/03 07:36 AM
Code:
on *:sockread:info:{
  if $sockerr { return }
  var %info | sockread %info
  while $sockbr { 
    if (&lt;td nowrap valign=top isin %info) { 
      var %info = [color:green]$spchrs($remove($gettok(%info,5,62),&lt;/td))[/color] - Infotec
      ; Do you need to write the info? (You don't for this code.)
      write -l4 scripts/news.txt %info
      sockclose info
      if (%info.last != %info) {
        set %info.last %info
        msg #NewsRoom 0,7»1,15 $time($calc($gmt +7200),HH:nn)) $+ CET &gt; %info 0,7«0,14 url .itec 
      }
    }
    sockread %info
  }
}
Edit: Of course, you will need the spchrs alias from the earlier post. smile
© mIRC Discussion Forums