LOGIN  |  REGISTER
Smart Living Made Brilliant!
CASTLEOS FORUM

HomeScripting

A forum for information about scripting with CastleOS. Get samples, suggestions, and other help here

A couple of scripting questions Messages in this topic - RSS

Grant Vallis
Grant Vallis
Posts: 6


3/27/2016
Grant Vallis
Grant Vallis
Posts: 6
Hi Chris,
I have a couple of scripting questions for you. The first one, will there be a way to store scripts in a repository folder on, say a shared folder so multiple "Kinect" PC's" can access them? This way the script and any accompanying files can be in one location instead of on each PC. If I try to read from a shared folder, the Kinect service crashes.
For example, I have written a program and script to compile from various RSS feeds and create a text file that the Kinect service can read and speak on command. I would like to call this command from anywhere in my house, but for now I have to have this program and script loaded on each Kinect PC.
My second question is about the script command ScriptingAPI.Speak(). Right now, I need to read in the entire text file before executing the ScriptingAPI.Speak() statement, otherwise it will start talking over itself. Is there a way to have the script read a line, then speak a line, then read, then speak, etc.?
Here is the script I wrote, you'll also be able to the commented "using" line for which I mentioned in my first question
using System; // Define system libraries
using System.IO;
using CastleOSKinectService;
public class RSSFeed
{
public void Main(string[] args)
{
using (StreamReader sr = new StreamReader("C:\\ProgramData\\CastleOS\\CastleOS Kinect Service\\Scripts\\RSSOutput.txt"))
// using (StreamReader sr = new StreamReader("L:\\RSSOutput.txt")) // Create instance of StreamReader & path/name of file
{
string line; // Define variable type
string msg; // Define variable type
msg = ""; // Clear contents
while ((line = sr.ReadLine()) != null) // Read lines from file until EOF
{
msg = msg + " " + line; // Add each line from file
}
msg = msg + " " + "End of Headlines"; // Add a closing comment
ScriptingAPI.Speak(msg); // Speak the headlines
}
}
}
Thanks
Grant
0 link
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390


3/27/2016
Chris Cicchitelli
Chris Cicchitelli
Administrator
Posts: 3390
Grant Vallis wrote:

For example, I have written a program and script to compile from various RSS feeds and create a text file that the Kinect service can read and speak on command. I would like to call this command from anywhere in my house, but for now I have to have this program and script loaded on each Kinect PC.


In theory, Symbolic Links will work for this, but we haven't tested it: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

Grant Vallis wrote:


My second question is about the script command ScriptingAPI.Speak(). Right now, I need to read in the entire text file before executing the ScriptingAPI.Speak() statement, otherwise it will start talking over itself. Is there a way to have the script read a line, then speak a line, then read, then speak, etc.?




You need to add a wait function for the number of seconds needed to let it complete the previous statement. Otherwise, you can do it exactly like you are now.
0 link