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!
I think that this can be achieved pretty easily with regexp & $chr as ' is ' and its ascii is 39...
alias spchrs {
var %a = $1-
while $regex(%a,/(&#\d*;)/) { var %a = $replace(%a,$regml(1),$chr($remove($regml(1),&#,;))) }
return %a
}
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.
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.
on *:sockread:info:{
if $sockerr { return }
var %info | sockread %info
while $sockbr {
if (<td nowrap valign=top isin %info) {
var %info = [color:green]$spchrs($remove($gettok(%info,5,62),</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 > %info 0,7«0,14 url .itec
}
}
sockread %info
}
}
Edit: Of course, you will need the spchrs alias from the earlier post.