It is currently March 29th, 2024, 7:19 am

Comparing Measures to determine True/False

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Comparing Measures to determine True/False

Post by Mor3bane »

Hideeho,

I am trying to compare Measures in a Calc:

Code: Select all

[MeasureTime2]
Measure=Calc
Formula=( 60 * ([MeasureHour] + [MeasureMinute]) )
IfCondition=((#CURRENTSECTION#>=[@CurrentSunriseTime])&&(#CURRENTSECTION#<[@CurrentSunsetTime]))
IfTrueAction=[!SetOption Mtsun ImageTint "235,235,155,255"] 
IfFalseAction=[!SetOption Mtsun ImageTint "55,106,129,255"] 
DynamicVariables=1
These are the measures the above are calculated from:

Code: Select all

[MeasureSunRiseHourString]
Measure=String
String=[@CurrentSunriseTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.*):.*$":"\1"

[MeasureSunRiseMinuteString]
Measure=String
String=[@CurrentSunriseTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^.*:(.*) .*$":"\1"

[MeasureSunriseHour]
Measure=Calc
Formula=[MeasureSunRiseHourString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunriseMinute]
Measure=Calc
Formula=[MeasureSunRiseMinuteString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunsetHourString]
Measure=String
String=[@CurrentSunsetTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.*):.*$":"\1"

[MeasureSunsetMinuteString]
Measure=String
String=[@CurrentSunsetTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^.*:(.*) .*$":"\1"

[MeasureSunsetHour]
Measure=Calc
Formula=[MeasureSunsetHourString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunsetMinute]
Measure=Calc
Formula=[MeasureSunsetMinuteString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunriseMoment]
Measure=Calc
Formula=( 60 * [MeasureSunriseHour] + [MeasureSunriseMinute] )
DynamicVariables=1
MaxValue=720
MinValue=0

[MeasureSunsetMoment]
Measure=Calc
Formula=( 60 * [MeasureSunsetHour] + [MeasureSunsetMinute] )
DynamicVariables=1
MaxValue=720
MinValue=0

[MeasureSunRisePercent]
Measure=Calc
Formula=( 3600 * [MeasureSunriseHour] + 60 * [MeasureSunriseMinute] )
DynamicVariables=1
MinValue=0
MaxValue=86400

[MeasureSunSetPercent]
Measure=Calc
Formula=( 3600 * [MeasureSunsetHour] + 60 * [MeasureSunsetMinute] )
DynamicVariables=1
MinValue=0
MaxValue=86400
I get this error with the above code:

Code: Select all

Logical expression error: IfCondition=((MeasureTime2>=12:00 )&&(MeasureTime2<12:00 ))
I am switching things around and consistently come up with another similar or even different error but always on the same line as it were.

Any suggestions?
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Comparing Measures to determine True/False

Post by mak_kawa »

Hi Mor3bane

I don't see the details of measures [@CurrentSunriseTime] and [@CurrentSunsetTime] in your post. But judging from the logical error message, they are still in "12:00" format of string? If so, it is natural that the conditional expression as "MeasureTime2>=12:00" causes that error.

What if you replace them with [MeasureSunriseMoment] and [MeasureSunsetMoment]?
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Comparing Measures to determine True/False

Post by Mor3bane »

mak_kawa wrote: August 28th, 2020, 12:23 am Hi Mor3bane...
...
What if you replace them with [MeasureSunriseMoment] and [MeasureSunsetMoment]?
That doesnt an error, but seems to always be true/or false.

I have changed some code since last testing that, but in the obvious case it is actually always false:

Code: Select all

[MeasureTime2]
Measure=Calc
Formula=( 60 * ([MeasureHour] + [MeasureMinute]) )
IfCondition=((#CURRENTSECTION#>=[MeasureSunriseMoment])&&(#CURRENTSECTION#<[MeasureSunsetMoment]))
IfTrueAction=[!SetOption Mtsun ImageTint "55,106,129,255"] 
IfFalseAction=[!SetOption Mtsun ImageTint "235,235,155,255"] 
DynamicVariables=1
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Comparing Measures to determine True/False

Post by mak_kawa »

Hi Mor3bane

I think, the formula that calculates "minutes" is incorrect in the measure [MeasureTime2].

Code: Select all

[MeasureTime2]
Formula=( 60 * ([MeasureHour] + [MeasureMinute]) )
Probably it has to be;

Code: Select all

[MeasureTime2]
Formula=( 60 * [MeasureHour] + [MeasureMinute] )
Sorry, if I am misunderstanding.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Comparing Measures to determine True/False

Post by Mor3bane »

mak_kawa wrote: August 28th, 2020, 1:16 am Hi Mor3bane

I think, the formula that calculates "minutes" is incorrect in the measure [MeasureTime2].

Code: Select all

[MeasureTime2]
Formula=( 60 * ([MeasureHour] + [MeasureMinute]) )
Probably it has to be;

Code: Select all

[MeasureTime2]
Formula=( 60 * [MeasureHour] + [MeasureMinute] )
Sorry, if I am misunderstanding.
Ive tried that as well - but the winning combination has eluded me. Ive switched it back to your recommendation.

I dont feel like putting fixed time numbers since i am not how to do that but id like to test for after sunset, without having to wait for sunset. I just an not too math savvy so I baulk at such things.

I tried this but it shows the same result as the other way round.
EDITED: This still does not work

Code: Select all


[MeasureTime2]
Measure=Calc
Formula=( 60 * [MeasureHour] + [MeasureMinute] )
IfCondition=((#CURRENTSECTION#<[MeasureSunriseMoment])&&(#CURRENTSECTION#>=[MeasureSunsetMoment]))
IfTrueAction=[!SetOption Mtsun ImageTint "55,106,129,255"] 
IfFalseAction=[!SetOption Mtsun ImageTint "235,235,155,255"] 
DynamicVariables=1

My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Comparing Measures to determine True/False

Post by mak_kawa »

Hi Mor3bane

Did you check each section value actually in the Open log -> Skins dialog? How are they?

And... did you check the result of actual IfCondition judging? To insert [!Log xxxx] bang to the IfTrueAction and IfFalseAction may help debugging (I always use this method).
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Comparing Measures to determine True/False

Post by eclectic-tech »

When trying to compare time, I find it easiest to use TimeStamp values. This eliminates the need to separate hours, minutes, and seconds and also having to deal with 12-hour am/pm values.

TimeStamp and TimeStampFormat can be confusing at times (pun intended :D ) but it simplifies comparing events. There are only a few measures needed to compare times and get percentages.
timestamp2.jpg
A time measure returns a Window TimeStamp as the number value for the current time.

The weather measures already provide a @CurrentSunriseTimeStamp and @CurrentSunsetTimeStamp values. It is then just a matter of setting the TimeStampFormat in your measure, to have Window TimeStamp values for sunrise, sunset. Note that you need to use the numeric section variable value in the IfCondition test.

Now you can compare 'apples-to-apples'.

To find percent values, use modulo math to acquire the seconds since the last full day of 86400 seconds.

Here are measures that use the values to compare in IfConditions and as percentage values.

Code: Select all

[MeasureTime2]
Measure=Time
IfCondition=((#CURRENTSECTION#<[MeasureSunriseMoment:])&&(#CURRENTSECTION#>=[MeasureSunsetMoment:]))
IfTrueAction=[!SetOption Mtsun ImageTint "55,106,129,255"] 
IfFalseAction=[!SetOption Mtsun ImageTint "235,235,155,255"] 
DynamicVariables=1

[MeasureSunriseMoment]
Measure=Time
TimeStamp=[@CurrentSunriseTimeStamp]
TimeStampFormat=%Y-%m-%dT%H:%M:%S
DynamicVariables=1

[MeasureSunsetMoment]
Measure=Time
TimeStamp=[@CurrentSunsetTimeStamp]
TimeStampFormat=%Y-%m-%dT%H:%M:%S
DynamicVariables=1

[MeasureSunRisePercent]
Measure=Calc
Formula=MeasureSunriseMoment%86400
DynamicVariables=1
MinValue=0
MaxValue=86400

[MeasureSunSetPercent]
Measure=Calc
Formula=MeasureSunsetMoment%86400
DynamicVariables=1
MinValue=0
MaxValue=86400
Hope this helps with your project.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Comparing Measures to determine True/False

Post by Yincognito »

eclectic-tech wrote: August 28th, 2020, 3:32 amTo find percent values, use modulo math to acquire the seconds since the last full day of 86400 seconds.
I don't particularly like Time measures (for various reasons), but this is a nice and simple approach. Why didn't I think of it? :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Comparing Measures to determine True/False

Post by brax64 »

Mor3bane wrote: August 27th, 2020, 11:35 pm
I get this error with the above code:

Code: Select all

Logical expression error: IfCondition=((MeasureTime2>=12:00 )&&(MeasureTime2<12:00 ))
I am switching things around and consistently come up with another similar or even different error but always on the same line as it were.

Any suggestions?
Hi Morebane,

I think you have a problem in the parsed measure for [@CurrentSunriseTime] and [@CurrentSunsetTime, seems that the timestamp is wrong...

Make sure to use the last update from jsmorley (here: https://forum.rainmeter.net/viewtopic.php?f=118&t=34628)

I did try this:

Code: Select all

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

[Variables]
@include=#@#WeatherComJSONVariables.inc
@include2=#@#WeatherComJSONMeasures.inc

[MeasureSunRiseHourString]
Measure=String
String=[@CurrentSunriseTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.*):.*$":"\1"

[MeasureSunRiseMinuteString]
Measure=String
String=[@CurrentSunriseTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^.*:(.*) .*$":"\1"

[MeasureSunriseHour]
Measure=Calc
Formula=[MeasureSunRiseHourString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunriseMinute]
Measure=Calc
Formula=[MeasureSunRiseMinuteString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunsetHourString]
Measure=String
String=[@CurrentSunsetTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(.*):.*$":"\1"

[MeasureSunsetMinuteString]
Measure=String
String=[@CurrentSunsetTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^.*:(.*) .*$":"\1"

[MeasureSunsetHour]
Measure=Calc
Formula=[MeasureSunsetHourString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunsetMinute]
Measure=Calc
Formula=[MeasureSunsetMinuteString]
RegExpSubstitute=1
Substitute="^\d{1,2}:(\d{1,2})$":"\1","^$":"0","\\":""
DynamicVariables=1

[MeasureSunriseMoment]
Measure=Calc
Formula=( 60 * [MeasureSunriseHour] + [MeasureSunriseMinute] )
DynamicVariables=1
MaxValue=720
MinValue=0

[MeasureSunsetMoment]
Measure=Calc
Formula=( 60 * [MeasureSunsetHour] + [MeasureSunsetMinute] )
DynamicVariables=1
MaxValue=720
MinValue=0

[MeasureSunRisePercent]
Measure=Calc
Formula=( 3600 * [MeasureSunriseHour] + 60 * [MeasureSunriseMinute] )
DynamicVariables=1
MinValue=0
MaxValue=86400

[MeasureSunSetPercent]
Measure=Calc
Formula=( 3600 * [MeasureSunsetHour] + 60 * [MeasureSunsetMinute] )
DynamicVariables=1
MinValue=0
MaxValue=86400

[MeasureHour]
Measure=Time
Format=%H

[MeasureMinute]
Measure=Time
Format=%M

[MeasureTime2]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
IfCondition=((#CURRENTSECTION#<[MeasureSunriseMoment])&&(#CURRENTSECTION#>=[MeasureSunsetMoment]))
IfTrueAction=[!SetOption Mtsun ImageTint 55,106,129,255]
IfFalseAction=[!SetOption Mtsun ImageTint 235,235,155,255]
DynamicVariables=1

[Mtsun]
Meter=Image
ImageName=#@#Images\vpn.png
PreserveAspectRatio=1
X=10
Y=10
AntiAlias=1
and it's working for me...
Hope this help..

Cheers
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Comparing Measures to determine True/False

Post by Mor3bane »

eclectic-tech wrote: August 28th, 2020, 3:32 am When trying to compare time, I find it easiest to use TimeStamp values. This eliminates the need to separate hours, minutes, and seconds and also having to deal with 12-hour am/pm values.

TimeStamp and TimeStampFormat can be confusing at times (pun intended :D ) but it simplifies comparing events. There are only a few measures needed to compare times and get percentages.
timestamp2.jpg
A time measure returns a Window TimeStamp as the number value for the current time.

The weather measures already provide a @CurrentSunriseTimeStamp and @CurrentSunsetTimeStamp values. It is then just a matter of setting the TimeStampFormat in your measure, to have Window TimeStamp values for sunrise, sunset. Note that you need to use the numeric section variable value in the IfCondition test.

Now you can compare 'apples-to-apples'.

To find percent values, use modulo math to acquire the seconds since the last full day of 86400 seconds.

Here are measures that use the values to compare in IfConditions and as percentage values.

Code: Select all

[MeasureTime2]
Measure=Time
IfCondition=((#CURRENTSECTION#<[MeasureSunriseMoment:])&&(#CURRENTSECTION#>=[MeasureSunsetMoment:]))
IfTrueAction=[!SetOption Mtsun ImageTint "55,106,129,255"] 
IfFalseAction=[!SetOption Mtsun ImageTint "235,235,155,255"] 
DynamicVariables=1

[MeasureSunriseMoment]
Measure=Time
TimeStamp=[@CurrentSunriseTimeStamp]
TimeStampFormat=%Y-%m-%dT%H:%M:%S
DynamicVariables=1

[MeasureSunsetMoment]
Measure=Time
TimeStamp=[@CurrentSunsetTimeStamp]
TimeStampFormat=%Y-%m-%dT%H:%M:%S
DynamicVariables=1

[MeasureSunRisePercent]
Measure=Calc
Formula=MeasureSunriseMoment%86400
DynamicVariables=1
MinValue=0
MaxValue=86400

[MeasureSunSetPercent]
Measure=Calc
Formula=MeasureSunsetMoment%86400
DynamicVariables=1
MinValue=0
MaxValue=86400
Hope this helps with your project.
Hi eclectic-tech
Yours works! This was so insane. Too many weather changes just mixed things up so nutzo. Thank you so very much!

Hi brax64
Yours always tested false no matter how things were arranged.

@eclectic-tech,
I did want to mention this error in the log comes up:

Code: Select all

Invalid TimeStampFormat: %Y-%m-%dT%H:%M:%S (Solar Time\Solar Time.ini - [MeasureSunriseMoment1])
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.