The aim was to overcome the problem that news feeds from the BBC sites don't list the topics with the most recent first. If you use a feed reader that just picks up the first 5-10 <title>(.*)</title> entries you may miss out on the most recent posts and you certainly won't see them in any chronological order .
The Lua Script was therefore updated to list the feed topics with the most recent at the top. The script reads 20 entries and the 10 most recent entries are then displayed by the skin. Any items posted since the skin was last updated are bulleted.
It's still not very elegant so I'd appreciate suggestions on how to tidy it up.
UPDATE: The first version was withdrawn becaues it crashed Rainmeter
The latest (24th July) version seems to work well enough without causing crashes
My apologies to anyone who downloaded the 1st Version
You do not have the required permissions to view the files attached to this post.
Last edited by Mordasius on July 26th, 2011, 12:34 am, edited 8 times in total.
Seahorse wrote:Was about to say this crashes Rainmeter in a big way...
Sorry about that. The problem, which I'd actually flagged in the LUA script, was that I was using SKIN:Bang("!RainmeterSetVariable PubDate"..tostring(n).." \""..Record.iPub.."\"") for all 20 items that had been read rather than just the top 10 displayed by the skin. This wasn't a problem while I was working on the script and refreshing it often but it crashed rainmeter when left doing its own thing on the desktop.
I'll post the corrected version after I've played a little more with the script.
Mordasius wrote:
Sorry about that. The problem, which I'd actually flagged in the LUA script, was that I was using SKIN:Bang("!RainmeterSetVariable PubDate"..tostring(n).." \""..Record.iPub.."\"") for all 20 items that had been read rather than just the top 10 displayed by the skin. This wasn't a problem while I was working on the script and refreshing it often but it crashed rainmeter when left doing its own thing on the desktop.
I'll post the corrected version after I've played a little more with the script.
One thing you have to be careful of, as was just discussed in this thread, http://rainmeter.net/forum/viewtopic.php?p=53042#p53042 is that when you send a value to a skin using the !RainmeterSetVariable (or just !SetVariable in newer betas) you need to "quote" any strings that have spaces in them, or Rainmeter will get very confused and think you are sending optional "Config" parameters on the bang.
jsmorley wrote:One thing you have to be careful of, as was just discussed in this thread, http://rainmeter.net/forum/viewtopic.php?p=53042#p53042 is that when you send a value to a skin using the !RainmeterSetVariable (or just !SetVariable in newer betas) you need to "quote" any strings that have spaces in them....
for i = 1, (iNumberToRead-iNumberToShow) do table.remove(tPubDate_Array) end
I'm now playing around with findpattern and string.match trying to find a neater way of reading an unknown number of <item> </item> entries from the text file.
P.S. On a realted matter
Is there any converter or wrapper or something that would allow us to quickly paste LUA scripts intended for Rainmeter in to SciTE for debugging and stepping?
"Is there any converter or wrapper or something that would allow us to quickly paste LUA scripts intended for Rainmeter in to SciTE for debugging and stepping?"
No, not at this time certainly. I'm not sure it would ever be possible given that the Lua is being executed within the larger C++ Rainmeter environment. About the only thing you can do is liberally use "print()" statements in your code, to send the values of variables and such to the Rainmeter log and view them in "About" while the skin is running. Then when all works, you can remove them from the Lua.
Ok Folks. The BBC Feed Reader has been fixed so that it doesn't crash Rainmeter.
The Lua Script reads 20 entries and then displays the 10 most recent entries with 'bullets' for any topics that are new since the feed was last read.
The LUA script is still pretty crude but I accept that this is not a LUA forum and don't expect suggestions on how to improve the bit which reads the text file and slaps it to a LUA table (that said any LUA experts are more than welcome to post or PM me with suggestions).
Last edited by Mordasius on July 22nd, 2011, 10:48 pm, edited 1 time in total.
Seems to work fine. I think there is still "something" that Rainmeter doesn't like, as it did crash Rainmeter one time, when it tried to load the skin the very first time when running the .rmskin. Might have been a coincidence as I do a LOT of testing of my own works in progress and stuff to help others, and my Rainmeter may have already been unstable, but I suspect there is something that Rainmeter is not liking.
Edit: I think part of the problem is this:
io.flush(hReadingFile)
That is my fault. It really should be io.close, not io.flush. We are leaving that .txt file "locked" open, even after the skin is unloaded, and I suspect that is causing an issue with runaway file handles or not allowing WebParser to recreate the file when the site updates. When it fails, it may be borking WebParser in general, which is going to cause all kinds of problems. I changed that, and I will beat it up to see if it remains stable.
The other thing I would be tempted to do is to send a bang at the end of the Update() in the Lua to re-"disable" the script measure. In other words, have the WebParser turn on the script using OnFinishAction when it goes out for the web site, and then have the script turn itself off again when it is done. I know you have an UpdateDivider on the script measure, but I'd be more comfortable in this case to have the WebParser measure "drive" things, rather than risk having the script trying to read the file at the same time the WebParser is trying to write it.
jsmorley wrote: Edit: I think part of the problem is io.flush(hReadingFile) ... should be io.close....
Thanks. I've fixed that in the latest version attached to the first post on this topic.
jsmorley wrote: The other thing I would be tempted to do is to send a bang at the end of the Update() in the Lua to re-"disable" the script measure.
I added SKIN:Bang("!DisableMeasure MeasureLuaScript") to the LUA script and there were no errors but there was still a value for MeasureLuaScript showing in the about view. I thought disabled measures showed 0.0 or blank. Just for fun I changed it to SKIN:Bang("!DisableMeasure \""..MeasureLuaScript.."\"") which effectively disabled the measure by crashing Rainmeter!
I'll test the new version as I'm on the BBC website all the time I've tinkered with it to match my current theme and played with font and spacing, seems to be stable so far.
Capture.PNG
You do not have the required permissions to view the files attached to this post.
"Regrettably your planet is one of those scheduled for demolition"
Mike