It is currently April 27th, 2024, 9:34 pm

Combine the results of two measures

Get help with creating, editing & fixing problems with skins
Kotofanchik
Posts: 95
Joined: March 15th, 2024, 7:30 pm

Combine the results of two measures

Post by Kotofanchik »

There are two measures
The result of their work is combined to display a picture.

Code: Select all

[MoonPhase]
Meter=image
MeasureName=mInPhase
MeasureName2=mPhase
imageName=#CURRENTPATH#Icons\%1%2
It works.
But you also need to combine their results in the same way to replace them with text messages using Substitute
for example mInPhase is "r" and mPhase is "100"
Then the image r100.png is displayed
And we need to somehow get the value of r100 to replace it with the text “full moon”
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Combine the results of two measures

Post by Yincognito »

Kotofanchik wrote: March 20th, 2024, 10:31 am There are two measures
The result of their work is combined to display a picture.

Code: Select all

[MoonPhase]
Meter=image
MeasureName=mInPhase
MeasureName2=mPhase
imageName=#CURRENTPATH#Icons\%1%2
It works.
But you also need to combine their results in the same way to replace them with text messages using Substitute
for example mInPhase is "r" and mPhase is "100"
Then the image r100.png is displayed
And we need to somehow get the value of r100 to replace it with the text “full moon”
There is no clear question in your post, so not sure anyone would know what you mean. So, I'll be the one to ask instead:
- do you want "r100.png", or "full moon.png" as your image?
- if the former, do you want "full moon" as some text displayed elsewhere?
Basically, I'm trying to find out if you want image "r100.png" and text "full moon", or both image "full moon.png" and text "full moon". Either way, you already answered your own (missing) question, using Substitute in the relevant measures (not meters) is the way to go.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 95
Joined: March 15th, 2024, 7:30 pm

Re: Combine the results of two measures

Post by Kotofanchik »

Yincognito wrote: March 20th, 2024, 5:40 pm image "r100.png" and text "full moon".
Kotofanchik
Posts: 95
Joined: March 15th, 2024, 7:30 pm

Re: Combine the results of two measures

Post by Kotofanchik »

I have two measures. One results in the letter r or s (increasing or decreasing), and the second results in the numbers: 0, 10, 25, 50, and so on.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Combine the results of two measures

Post by Yincognito »

Kotofanchik wrote: March 20th, 2024, 7:56 pm
Kotofanchik wrote: March 20th, 2024, 8:05 pm I have two measures. One results in the letter r or s (increasing or decreasing), and the second results in the numbers: 0, 10, 25, 50, and so on.
I assume the numbers are the percent of the moon being illuminated, right? If so, then, that's simple: create another String measure concatenating the strings from the measures providing the r/s and the 0/10/.../100, then add a Substitute to the new measure to "convert" its value to the "full moon" text and similar. Finally, for displaying the "full moon" and such texts, create another String meter referencing the newly created measure and you're done.

For example:

Code: Select all

[mInPhase]
Measure=...
...

[mPhase]
Measure=...
...

[mPhaseText]
Measure=String
String="[mInPhase][mPhase]"
RegExpSubstitute=1
Substitute="^r100$":"full moon",<the other possibilities and their replacements here, separated by commas>
DynamicVariables=1

...

[MoonPhase]
Meter=Image
...

[PhaseText]
Meter=String
MeasureName=mPhaseText
Text=%1
...
P.S. Sorry for the delay in responsding, had a busy day today.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 95
Joined: March 15th, 2024, 7:30 pm

Re: Combine the results of two measures

Post by Kotofanchik »

Yes, that's what I need. I couldn't combine into Measure. I tried a little at random, not understanding how to put parentheses there and what to write, but it didn’t work for me. Everything is fine now Thank you :)
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Combine the results of two measures

Post by Yincognito »

Kotofanchik wrote: March 20th, 2024, 11:36 pm Yes, that's what I need. I couldn't combine into Measure. I tried a little at random, not understanding how to put parentheses there and what to write, but it didn’t work for me. Everything is fine now Thank you :)
Excellent - you're welcome! :great:

By the way, forgot to mention, ^ means beginning of the string, and $ means the end of the string in regex. This is in order to replace only the said string, and not simply a string containing it. For example, if you don't use this and you have "r10":"blah","r100":"blahblah" then "r100" will never be properly replaced and will end up as "blah0", given that "r10" will be replaced first since "r100" contains "r10".
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 95
Joined: March 15th, 2024, 7:30 pm

Re: Combine the results of two measures

Post by Kotofanchik »

Yes, I don’t know these tricks, but I copied them just in case. It turns out not in vain. Otherwise, I would be racking my brains as to why the replacement didn’t work correctly.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Combine the results of two measures

Post by Yincognito »

Kotofanchik wrote: March 21st, 2024, 5:09 am Yes, I don’t know these tricks, but I copied them just in case. It turns out not in vain. Otherwise, I would be racking my brains as to why the replacement didn’t work correctly.
:thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth