Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1432

Help: Rainmeter Skins • Re: Improving my code

$
0
0
But, now I am beginning to work on the hourly forecast, in which there are 24 periods (hours), each of which may potentially have wind speed/gust, and humidex/wind chill. If the same technique were used, that would involve an additional 96 measures! So, I'm wondering if there are better ways of doing this?
It all depends on 2 things:
- how much you want to retrieve / display in your skin at once
- how is the source data structured / grouped in the XML
So, if you want to display the data for all 24 hours at the same time in your skin, then I think you'll need those extra 96 measures (and that's only for wind related stuff, besides the temps or whatever else you retrieve for those hours, of course).

On the other hand, if the XML structure permits, and you're ok with displaying fewer hours (divisors of 24) at the same time, you could get the whole day or week set and then use regex {quantifiers} to "browse" / "scroll" through them while only using that lower number of measures (probably multiplied by 4 as per your 4 fields, unless they're all text and next to each other to be combined in a single measure / meter, which doesn't seem to be the case).

One problem in your case might be the fields' volatility, i.e. that they could be missing, have their tags formatted differently, that kind of stuff. Other than that, the principle is simple, but it depends a lot on the particularities of your page source. Consider this basic pseudocode example, supposed to illustrate getting only 3 letters at a time from the 24 below:

Set: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,
Regex: (?siU)^(?:.,.,.,){#N#}(.),(.),(.),.*$
Out: first 3 letters for N=0, next 3 letters for N=1, etc.
Info: skip N batches of 3 letters and capture the next 3 letters

Obviously, the above is simplified to the max, to get the idea - a potential pattern in your case would be more complex, given all the edge cases, how fields are ordered / grouped in your XML, and the fact that you'll need to parse more data. It can be applied to any ordered structure in the source data.

But then again, this might not suit your case. Me, I use this technique extensively in the feeds and weather skins in my suite, to display only one feed or day part at a time, in a single set of non redundant measures / meters. Changing the "N" index dynamically is all it takes to capture the previous or next feed or day part. Most of the times I prefer a slightly more complex and flexible code than a simpler but longer one, but that's just me.

Statistics: Posted by Yincognito — Yesterday, 8:34 pm



Viewing all articles
Browse latest Browse all 1432

Trending Articles