Actual use of, any examples.
Conditional operator:
<condition> ? <expr. if true.> : <expr. if false.>
if (condition)
then
expr. if true
else
expr. if false
end if
It is currently November 29th, 2023, 10:05 pm
How to use the conditional operator
-
- Posts: 16
- Joined: September 4th, 2009, 11:39 am
-
- Posts: 667
- Joined: April 18th, 2010, 2:16 pm
- Location: NY, USA
Re: How to use the conditional operator
Alright, let's start:
[msConditionExample]
Measure=Calc
Formula=Random > 50 ? 1 : 2
DynamicVariables=1
IfAboveValue=1
IfAboveAction=!RainmeterMoveMeter 0 0 mtMeter
IfBelowValue=2
IfBelowAction=!RainmeterMoveMeter 10 10 mtMeter
So, what this says is if the formula is over 50 1 is the number spat out. If it's under 50 2 is the number spat out.
That way, 0-50=1 and 51-100=1 (technically it's more than 100 I think, but that's not the point)
Then, for the actions, if =1 the meter is moved to x=0 and y=0
If =2 the meter is moved to x=10 and y=10
Now, you can use DynamicVariables with this, or basically change anything in this to do something else. This code seems pretty useless in this example, but it does help.
The biggest thing it does that's useful that I can thing of is takes a range of numbers and makes it one number.
The part under the actual equation in your post is just what each value does in order.
[msConditionExample]
Measure=Calc
Formula=Random > 50 ? 1 : 2
DynamicVariables=1
IfAboveValue=1
IfAboveAction=!RainmeterMoveMeter 0 0 mtMeter
IfBelowValue=2
IfBelowAction=!RainmeterMoveMeter 10 10 mtMeter
So, what this says is if the formula is over 50 1 is the number spat out. If it's under 50 2 is the number spat out.
That way, 0-50=1 and 51-100=1 (technically it's more than 100 I think, but that's not the point)
Then, for the actions, if =1 the meter is moved to x=0 and y=0
If =2 the meter is moved to x=10 and y=10
Now, you can use DynamicVariables with this, or basically change anything in this to do something else. This code seems pretty useless in this example, but it does help.
The biggest thing it does that's useful that I can thing of is takes a range of numbers and makes it one number.
The part under the actual equation in your post is just what each value does in order.
-
- Posts: 16
- Joined: September 4th, 2009, 11:39 am
Re: How to use the conditional operator
Actually want to start a 1 plus 1 will be implemented until the 100 desktop display Meter, so I can play after the show finished animation Meter.
-
- Posts: 667
- Joined: April 18th, 2010, 2:16 pm
- Location: NY, USA
Re: How to use the conditional operator
Well, if I understand you correctly, you want something to keep adding by 1 until 100?
A counter is what you want. That updates by time.
Otherwise, you'd want
[Variables]
Variable=1
[msCalc]
Measure=Calc
Formula=#Variable#+1 = 1 ? 1 : #Variable#+1 = 2 ? 2 : #Variable#+1 = 3 ? #Variable#+1 = 4 ? 4 : #Variable#+1 = 5 ? 5: #Variable#+1 = 6 ? 6 : #Variable#+1 = 7 ? 7 : #Variable#+1 = 8 ? 8 : #Variable#+1 = 9 ? 9 : 10
DynamicVariables=1
For animation... that's not recommended. You could, theoretically have 10 slides in your animation and you would need a lot of repeptitive ifactions, but a bitmap is much better. http://rainmeter.net/cms/Tips-AnimatedGIF
A counter is what you want. That updates by time.
Otherwise, you'd want
[Variables]
Variable=1
[msCalc]
Measure=Calc
Formula=#Variable#+1 = 1 ? 1 : #Variable#+1 = 2 ? 2 : #Variable#+1 = 3 ? #Variable#+1 = 4 ? 4 : #Variable#+1 = 5 ? 5: #Variable#+1 = 6 ? 6 : #Variable#+1 = 7 ? 7 : #Variable#+1 = 8 ? 8 : #Variable#+1 = 9 ? 9 : 10
DynamicVariables=1
For animation... that's not recommended. You could, theoretically have 10 slides in your animation and you would need a lot of repeptitive ifactions, but a bitmap is much better. http://rainmeter.net/cms/Tips-AnimatedGIF
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: How to use the conditional operator
Code: Select all
[Variables]
Var=1
Max=100
[msCalc]
Measure=Calc
Formula=(#Var#+1)>=#Max#?#Max#:#Var#+1
DynamicVariables=1
[msSet]
Measure=Calc
Formula=msCalc
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable Var [msCalc]
DynamicVariables=1
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Posts: 16
- Joined: September 4th, 2009, 11:39 am
Re: How to use the conditional operator
2 only shows the desktop, without any calculation.
[Rainmeter]
update=1000
[Variables]
FontName=Bauhaus Lt BT
FontColor=255, 0, 0,
Var=1
Max=100
;[MeasureCalc]
;Measure=Calc
;Formula=Counter%#Max#
[msCalc]
Measure=Calc
Formula=(#Var#+1)>=#Max#?#Max#:#Var#+1
DynamicVariables=1
[msSet]
easure=Calc
Formula=msCalc
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable Var [msCalc]
DynamicVariables=1
[look]
Meter=STRING
MeasureName=msCalc
X=0
Y=0
FontColor=#FontColor# 100
FontSize=70
FontFace=#FontName#
Text=%1
StringAlign=LEFT
[Rainmeter]
update=1000
[Variables]
FontName=Bauhaus Lt BT
FontColor=255, 0, 0,
Var=1
Max=100
;[MeasureCalc]
;Measure=Calc
;Formula=Counter%#Max#
[msCalc]
Measure=Calc
Formula=(#Var#+1)>=#Max#?#Max#:#Var#+1
DynamicVariables=1
[msSet]
easure=Calc
Formula=msCalc
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable Var [msCalc]
DynamicVariables=1
[look]
Meter=STRING
MeasureName=msCalc
X=0
Y=0
FontColor=#FontColor# 100
FontSize=70
FontFace=#FontName#
Text=%1
StringAlign=LEFT
-
- Posts: 667
- Joined: April 18th, 2010, 2:16 pm
- Location: NY, USA
Re: How to use the conditional operator
What exactly are you trying to do?
-
- Posts: 509
- Joined: April 24th, 2009, 3:17 pm
- Location: Bucharest, Romania Lat 44,43° Lon 26,1°
Re: How to use the conditional operator
if you want to show only one measure in the meter with no additional text you do not need Text= in the meter code
Zero at programing, zero at writing codes, so far 2 at making images
But I'm good at copy/paste, and I not always like this
But I'm good at copy/paste, and I not always like this

-
- Posts: 16
- Joined: September 4th, 2009, 11:39 am
Re: How to use the conditional operator
If the formula can be calculated from 1 to 100 ,Naturally on the desktop display .
-
- Posts: 667
- Joined: April 18th, 2010, 2:16 pm
- Location: NY, USA
Re: How to use the conditional operator
What do you mean by 'Naturally on the desktop display'?
If you're just wondering if you can count to 100 in Rainmeter and stop, of course you can.
But as smurfier showed you, there's no condition just in case there was any confusion.
If you're just wondering if you can count to 100 in Rainmeter and stop, of course you can.
But as smurfier showed you, there's no condition just in case there was any confusion.