It is currently March 28th, 2024, 6:04 pm

How to write "IfCondition" correctly?

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to write "IfCondition" correctly?

Post by balala »

MaestroSky wrote: June 4th, 2021, 11:43 am Yes as you said it's too much and I cut it down, and so far it works and suits me, since I'm not going to extract more than 3 parameters:

Code: Select all

[MeasureCurrentTime]
Measure=Calc
IfCondition=(#Time# < MeasureCreated_at3) || ((MeasureCreated_at2 >= #Time#) && (MeasureCreated_at3 <= #Time#)) || ((MeasureCreated_at1 >= #Time#) && (MeasureCreated_at2 <= #Time#))
IfTrueAction=[!SetOption Meter1 Text "[MeasureCreated_at3]"]
IfTrueAction2=[!SetOption Meter1 Text "[MeasureCreated_at2]"]
IfTrueAction3=[!SetOption Meter1 Text "[MeasureCreated_at1]"]
IfFalseAction=[!SetOption Meter1 Text #Time#]
OnUpdateAction=[!UpdateMeter Meter1][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Actually the IfTrueAction without a corresponding IfCondition makes not too much sense. Even if on the above measure an IfTrueAction and an IfFalseAction, with the corresponding IfCondition are present, the IfTrueAction2 and IfTrueAction3 have no corresponding IfCondition2 and IfCondition3, so they do nothing.
MaestroSky wrote: June 4th, 2021, 11:43 am And as far as you understand that the parameters that are obtained are UNIX time. Now I try to translate it all into a normal display, but so far nothing comes out.
Yes, because there is a small mistake in the Formula option of the [MeasureUnixTimeToWindowsTime] measure. The [MeasureCurrentTime] (not posted) is supposablly a Time measure and as such adding its string value (represented by the first term of the sum within the Formula option - [MeasureCurrentTime]) is causing the measure not to return anything. So add the parameter to let the measure return its numeric value: Formula=[MeasureCurrentTime:]+[MeasureUnixTimeStart:].
In fact even better would be to add the time stamp of both measures used in the above Formula option. Something like this: Formula=[MeasureCurrentTime:TimeStamp]+[MeasureUnixTimeStart:TimeStamp].
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: How to write "IfCondition" correctly?

Post by MaestroSky »

balala wrote: June 4th, 2021, 5:36 pm Actually the IfTrueAction without a corresponding IfCondition makes not too much sense. Even if on the above measure an IfTrueAction and an IfFalseAction, with the corresponding IfCondition are present, the IfTrueAction2 and IfTrueAction3 have no corresponding IfCondition2 and IfCondition3, so they do nothing.

Yes, because there is a small mistake in the Formula option of the [MeasureUnixTimeToWindowsTime] measure. The [MeasureCurrentTime] (not posted) is supposablly a Time measure and as such adding its string value (represented by the first term of the sum within the Formula option - [MeasureCurrentTime]) is causing the measure not to return anything. So add the parameter to let the measure return its numeric value: Formula=[MeasureCurrentTime:]+[MeasureUnixTimeStart:].
In fact even better would be to add the time stamp of both measures used in the above Formula option. Something like this: Formula=[MeasureCurrentTime:TimeStamp]+[MeasureUnixTimeStart:TimeStamp].
What I just haven't tried is not getting the information from [MeasureCurrentTime] to [MeasureTimeConvert]

Code: Select all

[Rainmeter]
Update=1000
DefaultUpdateDivider=1
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=background2

[Variables]
UpdateTime=10
Time=1332854574


[MeasureCurrentTime]
Measure=Calc
IfCondition=(#Time# < MeasureCreated_at3) || ((MeasureCreated_at2 >= #Time#) && (MeasureCreated_at3 <= #Time#)) || ((MeasureCreated_at1 >= #Time#) && (MeasureCreated_at2 <= #Time#))
IfTrueAction=[!SetOption Meter1 Text "[MeasureCreated_at3]"]
IfTrueAction2=[!SetOption Meter1 Text "[MeasureCreated_at2]"]
IfTrueAction3=[!SetOption Meter1 Text "[MeasureCreated_at1]"]
IfFalseAction=[!SetOption Meter1 Text #Time#]
OnUpdateAction=[!UpdateMeasure MeasureUnixTimeToWindowsTime][!Redraw]
UpdateDivider=1
DynamicVariables=1

[InfoGM]
Measure=WebParser
URL=https://api.worldoftanks.ru/wot/clans/list/?application_id=bf049cf6db102d4f0536904348d02500
RegExp={"status":.*color":"(.*)","created_at":(.*),"tag":.*color":"(.*)","created_at":(.*),"tag":.*color":"(.*)","created_at":(.*),"tag":
DynamicVariables=1
UpdateRate=#UpdateTime#

[MeasureCreated_at1]
Measure=WebParser
URL=[InfoGM]
StringIndex=2
OnChangeAction=[!UpdateMeasure MeasureCurrentTime]
DynamicVariables=1

[MeasureCreated_at3]
Measure=WebParser
URL=[InfoGM]
StringIndex=4
OnChangeAction=[!UpdateMeasure MeasureCurrentTime]
DynamicVariables=1

[MeasureCreated_at2]
Measure=WebParser
URL=[InfoGM]
StringIndex=6
OnChangeAction=[!UpdateMeasure MeasureCurrentTime]
DynamicVariables=1

;=========================================================
;  MeasureCreated_at1  MeasureCreated_at2  MeasureCreated_at3
;=========================================================
[Meter2]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureCreated_at1
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
AntiAlias=1
X=0
Y=5R
W=300
H=30
Text=MeasureCreated_at1: %1
ToolTipType=1
DynamicVariables=1
Hidden=0

[Meter3]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureCreated_at2
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
AntiAlias=1
X=0
Y=15r
W=300
H=30
Text=MeasureCreated_at2: %1
ToolTipType=1
DynamicVariables=1
Hidden=0

[Meter4]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureCreated_at3
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
AntiAlias=1
X=0
Y=15r
W=300
H=30
Text=MeasureCreated_at3: %1
ToolTipType=1
DynamicVariables=1
Hidden=0

; Time Convert

[MeasureUnixTimeStart]
Measure=Time
TimeStamp=00:00:00 01/01/1970
TimeStampFormat=%H:%M:%S %d/%m/%Y
FormatLocale=Local
UpdateDivider=-1
DynamicVariables=1

[MeasureUnixTimeToWindowsTime]
Measure=Calc
Formula=[MeasureCurrentTime:TimeStamp]+[MeasureUnixTimeStart:TimeStamp]
DynamicVariables=1

[MeasureTimeConvert]
Measure=Time
TimeStamp=[MeasureUnixTimeToWindowsTime]
Format=%H:%M:%S %d/%m/%Y
FormatLocale=Local
DynamicVariables=1
Substitute="00:00:00 01/01/1970":"-"

[Meter5]
Meter=String
MeterStyle=styleRightText
MeasureName=MeasureTimeConvert
StringStyle=Bold
FontFace=Roboto Condensed
FontSize=10
AntiAlias=1
X=0
Y=15r
W=300
H=30
Text=Time: %1
ToolTipType=1
DynamicVariables=1
Hidden=0
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to write "IfCondition" correctly?

Post by balala »

MaestroSky wrote: June 5th, 2021, 8:05 am What I just haven't tried is not getting the information from [MeasureCurrentTime] to [MeasureTimeConvert]
So finally I am not entirely sure. Does the code work?
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: How to write "IfCondition" correctly?

Post by death.crafter »

MaestroSky wrote: June 5th, 2021, 8:05 am What I just haven't tried is not getting the information from [MeasureCurrentTime] to [MeasureTimeConvert]

Code: Select all

[MeasureCurrentTime]
Measure=Calc
IfCondition=(#Time# < MeasureCreated_at3) || ((MeasureCreated_at2 >= #Time#) && (MeasureCreated_at3 <= #Time#)) || ((MeasureCreated_at1 >= #Time#) && (MeasureCreated_at2 <= #Time#))
IfTrueAction=[!SetOption Meter1 Text "[MeasureCreated_at3]"]
IfTrueAction2=[!SetOption Meter1 Text "[MeasureCreated_at2]"]
IfTrueAction3=[!SetOption Meter1 Text "[MeasureCreated_at1]"]
IfFalseAction=[!SetOption Meter1 Text #Time#]
OnUpdateAction=[!UpdateMeasure MeasureUnixTimeToWindowsTime][!Redraw]
UpdateDivider=1
DynamicVariables=1
Wait, does the ifcondition work in this manner? Just curious. Cause IfTrueAction2 and up have no conditions at all.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to write "IfCondition" correctly?

Post by Yincognito »

death.crafter wrote: June 5th, 2021, 3:50 pm Wait, does the ifcondition work in this manner? Just curious. Cause IfTrueAction2 and up have no conditions at all.
You're right - balala mentioned this in one of his last posts too. Personally I'm still trying to understand what was the goal here and if it's in some ways related to the OP's other post here...
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: How to write "IfCondition" correctly?

Post by death.crafter »

Yincognito wrote: June 5th, 2021, 4:20 pm You're right - balala mentioned this in one of his last posts too. Personally I'm still trying to understand what was the goal here and if it's in some ways related to the OP's other post here...
With what he's trying to achieve, he could have just used ths instead of a lot of confusing ifConditions, https://forum.rainmeter.net/viewtopic.php?f=5&t=37648&start=10#p191467. But any way, as jsmorely says, each to his own.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to write "IfCondition" correctly?

Post by Yincognito »

death.crafter wrote: June 5th, 2021, 4:39 pm With what he's trying to achieve, he could have just used ths instead of a lot of confusing ifConditions, https://forum.rainmeter.net/viewtopic.php?f=5&t=37648&start=10#p191467. But any way, as jsmorely says, each to his own.
For sure, if his goal was to get the maximum of those. Heck, I'm using such formulas for something like 32 CPU temperature values to get the highest of them - using IfConditions for that task would certainly be overkill. That's why I was wondering what the OP's actual goal in his skin is. Maybe some things can be done easier once you know the expected result. Folks sometimes simplify their skins before asking questions on the forum, and that makes the actual goal / expected result of the process a bit blurry.
Post Reply