|
ECS-L Home Automation and Security Archives |
learn more
| view messages for this
month | NetBloc® | terms of use | search
subject (prev) or (next) |
time (prev) or (next) |
author (prev) or (next) |
view more subjects
Subject: From: Date: | Event to speak messages from a text file Martin Terry Sun, 14 Nov 1999 12:19:57 -0800 |
ECSers,
Here's another event that I found pretty useful. It is very similar to the
last I posted. Basically I wanted some way for ECS to speak some kind of
informative messages, but I didn't want to have to define dozens of
different text items for this purpose. So I created a single text item
called Msg:Generic that is defined from text files. These files all live in
a directory called d:\msg.
All the files are basically single line ascii text files that are named
numerically (E.G. 1,2,3,4) I have a list of the numbers and the messages
they contain.
Here's the contents of d:\msg\1
There is a new phone message.
So in my phone event I set a numeric item Num:MsgPointer to 1 and call the
event to read the file and speak the message, like so:
| ;Announce phone messages when a message is left
| If Sys:NewPhoneMsgs Is 1
| And Time:CurrentTime Is LT Time:Bedtime
| Then Num:MsgPointer Set 1
| Then Sys:EventCall Set
Called:SpeakMsg
And ECS says "There is a new phone message". Here's the event that is
called:
|Event: Called:SpeakMsg Called ?:Yes
| ;Dynamically define a Text Message and speak
| ;To use set Num:MsgPointer to the message desired
| ;Then Call Called:SpeakMsg
|
| If Num:MsgPointer Is 0
| Then Sys:EventExit Set True
|
| ;Setup the path to the message
| Do Msg:Generic T1<-T1 Str:MessagePath
| Do Msg:Generic T1/A<-Stt Num:MsgPointer
| Do File:GenericTxt T1<-T1 Msg:Blank
| Do File:GenericTxt T1<-T1 Msg:Generic
| Do Num:MsgPointer Set 0
| Do File:GenericTxt Set Rewind
| Do Num:GetChar Set 0
| Do Flg:Loop Set True
| Do Msg:Generic T1<-T1 Msg:Blank
|
| ;Loop through and get characters
| WHILE Flg:Loop Is True
| Do Num:GetChar Set File:GenericTxt
| If Num:GetChar Is Not 10
| And Num:GetChar Is Not 13
| And Num:GetChar Is Not 256
| Then Msg:Generic Set Num:GetChar
| If Num:GetChar Is 256
| Then Flg:Loop Set False
| ENDWHILE
|
| ;Add a warning chime if desired
| If Flg:Chime Is False
| Then Flg:Chime Set True
| Else SFX:Announce Set Play
|
| ;Speak the message
| Do Msg:Generic Set Speak
| Do Sys:EventExit Set True
| End
Hopefully it is simple enough to follow.
subject (prev) or (next) |
time (prev) or (next) |
author (prev) or (next) |
view more subjects