emp00 wrote: ↑March 20th, 2024, 8:20 pmHowever, is it true that I now have to write
167 (one-hundred-sixty-seven?!) measures copy/pasted "only" counting up the X and setting up unique measure names? This seems super-inefficient, ism't there a more simple way to query the complete array in
one measure and then use this single array-measure in a meter drawing the trend line graph and also for calculating e.g. the daily peak or daily sum of irradiance etcpp...?
Yes, I know that practically all weather skins are actually using such series of unique measures for such purposes, but maybe there is a better way thanks to the JSON parser or other tricks? I mean in any other programming language you'd write a simple loop to "cover it all".
Everythings possible, right? Thanks for any hints...
Very good question. Actually, there is, but you won't like it. The reason is simple: given that, even with the help of Lua (which does have very fast arrays, called "tables"), Rainmeter just doesn't have an "array" type of variable (everything in Rainmeter is "single instance"), the only way to have multiple "values" into one variable is to manipulate strings, which basically translates to ... prepare yourself ... the mighty regex, lol (attention, I'm not talking about the WebParser's RegExp option!). Or, you can build the string in Lua, but you'd use Lua's own form of regex, called "patterns". Heck, even the JsonParser uses some form of "regex" (i.e. string finding and manipulation) to do its thing, the only difference is that it does it internally, saving the user the trouble of doing it himself. To put it in a simple way, regex is for strings what is math for numbers.
You won't get away with a single measure though, you'd have to have at least two or maybe four, since you have 2 graphs (precipitation and irradiance), but yeah, you could end up with the entire code in a one or two Notepad++ pages if done properly. The only reason I didn't mentioned this approach in the other thread was that I thought you needed individual values for some individual displaying / mouse actions on the values (which many users insist in doing), but now that you asked, yes, it can be done in a much shorter way, but you won't escape regex. The idea would be to take the entire precipitation and irradiance sets / arrays / strings in the json response, and build the precipitation and irradiance Paths based on that. In essence, replacing the
, between those values with
| LineTo (the rest of the graph formulas here) in order to build the Path's string value, then using the outcome as the value of the Path's options. So, you'd "automatically" build the graph based on the array string extracted from the site's response.