Asked — Edited

Rss News

Hey guys, here is a script I have been working on. It reads the Rss News and after it is done with the first story it asks you if you want to continue. If you say "Yes" it will continue to the second story, and if you say "NO" it will end the script. I didn't know if this was posted already somewhere but I thought I would share it anyways . RSSNEWS.EZB:D


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

#1  

Thank you cafasru! bookmarked!

#2  

BTW, I tried running the script in a friends house and it gave me an error, I simply initiated $storyLn = 0, ran the script and said no to "do you want me to continue". deleted the " = 0" for the $storyLn and ran it again, it worked perfectly. Not sure why it did this.

United Kingdom
#3  

I'll have a proper look later but have had a quick look without ARC.

If you have any variables that are in an IF condition i.e. IF($xyz =0) or part of a math function i.e. $xyz++ then the variable must exist prior to the IF. Otherwise ARC doesn't know what they are and will throw back an error. Imagine if someone said to you to work out $x + 27, what's the answer? Without $x you can't work it out.

In your script you have $sentinel and $storyLn both which don't exist. You almost had it right though by declaring them at the start but you need to do it like;


$sentinel = "no"
$storyLn = 0

You may also need to move them to before the begin loop label if resetting them during the loop shouldn't happen.

Hope that helps.

#4  

Rich, thanks for your input, I did try to initialize them before the loop and setting the $sentinel with a value, but to be honest this is the only way it worked for me. Let me know if you get a chance to run it through ARC. I included a line to print the value of $storyLn and it does update as you say "Yes" and the counter resets only after resetting at the end of the loop. Ill give it an other shot when I get home and let you guys know.

United Kingdom
#5  

Try this...


# Define variables
$sentinel = 0
$storyLn = 0

# Start the code
:begin
$storyLn++ 
Print($storyLn)

SpeakRSSDescription("http://feeds.reuters.com/Reuters/domesticNews",$storyLn)
SayWait("Would you like me to continue?")
$sentinel = WaitForSpeech(10,"YES","NO")

if ($sentinel == "YES")
Goto(begin)

Else
$storyLn = 0
SayWait("Ok")
Endif

#6  

Got it! Thanks! do you think I even need the sentinel at all? I even think I can get rid of that too. since the variable is assigned at the $sentinel = WaitForSpeech(10,"YES","NO"), correct? Thank alot.

United Kingdom
#7  

You can get rid of it from the start yes. However, I generally set out all variables at the start of a script for three reasons;

  1. To avoid any errors if the variable isn't defined before any IF or calculations.
  2. To reset all variables if a script is stopped then restarted.
  3. So I know what the variables are (the amount I use I tend to lose track)

While it may be redundant and makes the script longer I prefer it that way, but that's just my way I guess, each person will do things differently.

#8  

Why do I only get the same news item, it does not read me the next. Other than that it works great.