It is currently March 28th, 2024, 10:23 pm

How to write "IfCondition" correctly?

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: How to write "IfCondition" correctly?

Post by CodeCode »

The "fall-through logic" seems flawed, since you jump from less than ##at1, to greater then ##at2 and less than ##at3.

There needs to be a line after less than ##at1 that says; greater than ##at1 and less than ##at2.

The next part is conflicting with previous lines; greater than ##at3 and less than ##at2, would mean that ##at1 and ##at3 hold the same range, and that breaks the fall through logic.

If you goal is solely to compare that values as stated, the fall through logic needs to be considered.

Just asking, you understand 'fall through logic'? - it is like a sieve that starts at big holes and ends in fine grit holes. (not a perfect analogy as I myself struggle with these tbh).
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: How to write "IfCondition" correctly?

Post by death.crafter »

MaestroSky wrote: June 2nd, 2021, 3:52 pm The U parameter is now less than Mesuare..at2 by 1
Which means that the data should show me the Mesuare values..at2 a shows me the U values.
At this point you better use this:

Code: Select all

[MeasureCurrentTime]
Measure=Calc
Formula=Max(Max(MeasureCreated_at1,MeasureCreated_at2),Max(MeasureCreated_at3,[#U]))
DynamicVariables=1
UpdateDivider=-1

[Meter1]
...
MeasureName=MeasureCurrentTime
Here you need no if conditions. It will return the largest of them all(I guess that's what you want).
from the Realm of Death
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 2nd, 2021, 3:52 pm The U parameter is now less than Mesuare..at2 by 1
Which means that the data should show me the Mesuare values..at2 a shows me the U values.
Don't know, because it does work for me (I added an almost white background to the [Meter1] meter and another string meter, which shows the values of the three measures):
Skin.png
However what could cause a problem is the fact that there are three set of IfConditions, each with an IfTrueAction / IfFalseAction options pair. There is executed one of each pair of such options and this might cause troubles. There always is a good idea not to have both IfTrueAction and IfFalseAction options if more then one single IfCondition is used. Not forbiden, but not a good idea is either.
So not sure what to say. Maybe try packing the whole config and upload the package here, to can check it exactly as are you using it.
You do not have the required permissions to view the files attached to this post.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: How to write "IfCondition" correctly?

Post by MaestroSky »

balala wrote: June 2nd, 2021, 5:33 pm Don't know, because it does work for me (I added an almost white background to the [Meter1] meter and another string meter, which shows the values of the three measures):
Skin.png
However what could cause a problem is the fact that there are three set of IfConditions, each with an IfTrueAction / IfFalseAction options pair. There is executed one of each pair of such options and this might cause troubles. There always is a good idea not to have both IfTrueAction and IfFalseAction options if more then one single IfCondition is used. Not forbiden, but not a good idea is either.
So not sure what to say. Maybe try packing the whole config and upload the package here, to can check it exactly as are you using it.
Yes it only works on IfCondition2= and IfCondition3=
In this case, we have the minimum value from the list is 1343233684 if the U parameter contains a number less than 1343233684, then nothing happens. Rather, the entry comes from the U parameter.
Many variables are possible for it. I'll think about how to solve it.
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 2nd, 2021, 7:11 pm Yes it only works on IfCondition2= and IfCondition3=
In this case, we have the minimum value from the list is 1343233684 if the U parameter contains a number less than 1343233684, then nothing happens. Rather, the entry comes from the U parameter.
Many variables are possible for it. I'll think about how to solve it.
For me it does work for IfCondition as well. Tried comment out IfCondition2 / IfTrueAction2 / IfFalseAction2 and IfCondition3 / IfTrueAction3 / IfFalseAction3 and did still work. Try it out, commenting out these options and try again.
Still recommend to pack the config and upload the package here, to can check.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: How to write "IfCondition" correctly?

Post by MaestroSky »

balala wrote: June 2nd, 2021, 7:29 pm For me it does work for IfCondition as well. Tried comment out IfCondition2 / IfTrueAction2 / IfFalseAction2 and IfCondition3 / IfTrueAction3 / IfFalseAction3 and did still work. Try it out, commenting out these options and try again.
Still recommend to pack the config and upload the package here, to can check.
You do not have the required permissions to view the files attached to this post.
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 2nd, 2021, 7:44 pm
As said, the result shown by the [Meter1] meter is altered by all three set of IfTrueAction / IfFalseAction options. If you comment out the last set of IfConditions (IfCondition3 / IfTrueAction3 / IfFalseAction3), you get the proper result, because even if the IfTrueAction and IfFalseAction options are setting the appropriate value for the option, the result is altered by this (just commented out) options and this is why the meter show something else. IfCondition (and the corresponding IfTrueAction / IfFalseAction) does definitely work. Well.
As said, it's not a good idea to use both IfTrueAction and IfFalseAction if there are more IfConditions. Things might go in a very unpleasant directions, which happened this time as well. It's not forbidden, but not a good idea is either.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: How to write "IfCondition" correctly?

Post by MaestroSky »

balala wrote: June 2nd, 2021, 8:08 pm As said, the result shown by the [Meter1] meter is altered by all three set of IfTrueAction / IfFalseAction options. If you comment out the last set of IfConditions (IfCondition3 / IfTrueAction3 / IfFalseAction3), you get the proper result, because even if the IfTrueAction and IfFalseAction options are setting the appropriate value for the option, the result is altered by this (just commented out) options and this is why the meter show something else. IfCondition (and the corresponding IfTrueAction / IfFalseAction) does definitely work. Well.
As said, it's not a good idea to use both IfTrueAction and IfFalseAction if there are more IfConditions. Things might go in a very unpleasant directions, which happened this time as well. It's not forbidden, but not a good idea is either.
Yes indeed as you said it is not advisable for it to use too much IfFalseAction=
So I commented out IfFalseAction2 and IfFalseAction3 and got the result I needed.

Code: Select all

[MeasureCurrentTime]
Measure=Calc
IfCondition=#Time# < MeasureCreated_at3
IfTrueAction=[!SetOption Meter1 Text "[MeasureCreated_at3]"]
IfFalseAction=[!SetOption Meter1 Text #Time#]
IfCondition2=(MeasureCreated_at2 >= #Time#) && (MeasureCreated_at3 <= #Time#)
IfTrueAction2=[!SetOption Meter1 Text "[MeasureCreated_at2]"]
;IfFalseAction2=[!SetOption Meter1 Text #*Time*#]
IfCondition3=(MeasureCreated_at1 >= #Time#) && (MeasureCreated_at2 <= #Time#)
IfTrueAction3=[!SetOption Meter1 Text "[MeasureCreated_at1]"]
;IfFalseAction3=[!SetOption Meter1 Text #*Time*#]
OnUpdateAction=[!UpdateMeter Meter1][!Redraw]
UpdateDivider=-1
DynamicVariables=1
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 3rd, 2021, 5:50 am Yes indeed as you said it is not advisable for it to use too much IfFalseAction=
So I commented out IfFalseAction2 and IfFalseAction3 and got the result I needed.
I'm glad, however me personally still have a problem with this. If an IfFalseAction still exist, one of the IFTrueAction2 or IfTrueAction3 options in some circumstances might "overwrite" IfFalseAction. All these options are setting a Text option for the [Meter1] meter and if more than one single of them can be executed in the same time, sooner or later an overlap might occur. I tend to use either a single IfCondition with the appropriate IfTrueAction and IfFalseAction, or if multiple IfConditions are needed, use only IfTrueActions, but not a single IfFalseAction. Otherwise you have to be EXTREMELY careful on how are you adding the conditions.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: How to write "IfCondition" correctly?

Post by MaestroSky »

balala wrote: June 3rd, 2021, 2:33 pm I'm glad, however me personally still have a problem with this. If an IfFalseAction still exist, one of the IFTrueAction2 or IfTrueAction3 options in some circumstances might "overwrite" IfFalseAction. All these options are setting a Text option for the [Meter1] meter and if more than one single of them can be executed in the same time, sooner or later an overlap might occur. I tend to use either a single IfCondition with the appropriate IfTrueAction and IfFalseAction, or if multiple IfConditions are needed, use only IfTrueActions, but not a single IfFalseAction. Otherwise you have to be EXTREMELY careful on how are you adding the conditions.
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
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.

Code: Select all

; Time Convert

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

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

[MeasureTimeConvert]
Measure=Time
TimeStamp=[MeasureUnixTimeToWindowsTime]
Format=%H:%M:%S %d/%m/%Y
DynamicVariables=1
Substitute="03: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
But most likely this is another story that does not apply to this topic.