The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

News Headline Script for xplhal


  • Subject: News Headline Script for xplhal
  • From: Tony T
  • Date: Sun, 02 Mar 2003 09:58:00 +0000

Hi all,

This is a news headline script (based around a script by Amar Nagi) for
xPLHal that reads out the yahoo news headlines via xPL TTS messages. I've
added it to my wake up macro. I also have an xPL OSD version.

It requires the latest v3.01 version of xPLHal (just published) and an xPL
TTS app.

Though it could easily be modified for other vbscript ha systems.

sub HeadlinesTTS()

Dim sRawWeb, iPos1, iPos2, sPara, icnt

' announce
mymsg="SPEECH=Todays Headlines are;"
call xpl.sendmsg("","","TTS.BASIC",mymsg)

' Get the Webpage
sRawWeb = sys.gethttp("<a href="http://uk.yahoo.com/";>http://uk.yahoo.com/</a>",40000,5)
if sRawWeb = "" then
mymsg="SPEECH=not available, sorry."
call xpl.sendmsg("","","TTS.BASIC",mymsg)
exit sub
end if

'Find the positions in Page
iPos1 = InStr(1, sRawWeb, "In The News", vbTextCompare)
iPos2 = InStr(iPos1, sRawWeb, "<tr><td colspan=2>",
vbTextCompare)

' Kill some ugly characters and replace with period
sPara = Replace(Mid(sRawWeb, iPos1, iPos2 - iPos1),
"&amp;#149;;", ".")

'Split the String By Period into an array
snews = Split(sPara, "</a>", -1, 1)

' Walk through the array and speak the headlines
For icnt = 0 To UBound(snews) - 1
x = InStr(1, snews(icnt), ".html>", vbBinaryCompare)
if icnt=ubound(snews)-1 then
mymsg="SPEECH=and finally, " &amp;
RTrim(LTrim(Mid(snews(icnt), x + 6))) &amp; ";"
else
mymsg="SPEECH=" &amp; RTrim(LTrim(Mid(snews(icnt), x +
6))) &amp; ";"
end if
call xpl.sendmsg("","","TTS.BASIC",mymsg)
Next

End Sub

Regards
Tony






xPL Main Index | xPL Thread Index | xPL Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.