Jeff wrote: ↑July 11th, 2023, 8:42 pm
I imagine that for the CPU
measure, the reason why the Substitute
dosen't show in the Log, but works fine on the meter is because the Substitute
might be applied after NumOfDecimals=0
Your assumption is almost correct - and no, this isn't a bug, it has to do with how Rainmeter works internally. Take a look here
(at when, where and on what the substitution is performed from the first post, and also at the subsequent replies on a somewhat related topic, if you're interested) for some insight on how it works. The main thing here is that generally and a bit counterintuitively (but in a way, similar to how dynamic variables or bangs operate too), the substitution mostly happens when the measure is used
(in your meter, in this case), and on that used value
- it doesn't happen like you'd expect, strictly when the measure it is attached to is updated.
This is why, in your case, you can get away with a substitute that only takes into account integer values (like your substitute does), even though the measure, bar the initial "0" value, yields mostly fractional values for the CPU usage (e.g. 15.36765 and not 15). So, the substitution happens when your measure is referenced in the related meter, and by that time, because of the default 0 number of decimals in the meter, the numeric value of the measure there is reduced to an integer value, before being handled as a string. That is also why you don't get the expected 0 padded string value in the log, because to get that, you'd have to operate on the string representation of the "true" fractional numerical value of the measure (and not on its decimal stripped value it's constrained to in the meter). Even after taking these into account, you still won't get the desired string both in the log and the meter, unless you specifically use the measure's string value as a section variable, obviously enabling dynamic variables in the meter as well, like this:
Code: Select all
InLineSetting=Shadow | 1 | 1 | 2 | ABCDEF
Take a look at [StringB] and [Meter2] for comparison with the previous code. Naturally, since we don't strip decimals from the measure's numerical value anymore but we do it on its string value, the displayed value is in fact truncated and not rounded. I assumed here that the measure will always have fractional values, disregarding the few exception cases, so if you need that, you'd have to make the decimal dot and the following stuff optional by adding a question mark (?) after the desired expression (e.g. \.?\d*?
in the above case), or fake fractional values like below.
: On zero or space padding substititions - they can be done in a more general fashion, e.g.:
Code: Select all
for an integer value padded to a 5 digit string (the easiest example). Two substitutions is all it takes: one to add the maximum number of padding characters (4 since at least 1 character is assumed for the original string), the other to remove the surplus characters (what's more than 5 chars). You can use a similar approach for digits after the decimal point or even when combining the padding characters, e.g.:
Code: Select all
for a fractional value that has its integer part space padded to a 3 char string and its fractional part zero padded to a 2 char string, like 3.20
. The first substitution simply fakes a decimal point after an integer value, to make things more consistent in the following substitutions. Needless to say, having a - or a + before the value (like for weather temps) adds some bits to the subs, but that's to be expected anyway.