It is currently April 19th, 2024, 10:26 am

IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

I guess I just don't understand what you are trying to do. What possible value does it bring to go out to the web and get the "current" time as a Unix timestamp? The current time as a Unix timestamp is simply:

Code: Select all

[MeasureCurrentTimeToUnix]
Measure=Time
Timestamp=([MeasureCurrentTimeToUnix]-11644473600)
DynamicVariables=1
Now that isn't a value you want to display as a formatted time, as it won't make any sense. But it will create a number of seconds since 1970 that can be compared to the static #UnixTime# variable you have set.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

Code: Select all

[Variables]
UnixTime=1619766794

[InfoUnixTime]
Measure=WebParser
URL=https://converter.by/unixtime
UpdateRate=#UpdateTime#
RegExp="(?siU)<span class="btn btn-dark-green current-unix-time" id="current-unix-time">(.*)</span>"
UpdateDivider=-1
DynamicVariables=1

[MeasureInfoUnixTime]
Measure=WebParser
URL=[InfoUnixTime]
StringIndex=1
;RegExpSubstitute=1
DynamicVariables=1
UpdateDivider=-1

[Meter]
Meter=String
IfCondition=(#UnixTime# > [MeasureInfoUnixTime])
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!RainmeterShowMeter MeterCount]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!RainmeterHideMeter MeterCount]
DynamicVariables=1
But after all, the

Code: Select all

[Meter]
doesn't fire properly.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

We need to solve the underlying need you have before we address the fact IfCondition can NEVER be used on a "meter", but must be used on a "measure".
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

Code: Select all

[MeasureCurrentTime]
Measure=Time

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
DynamicVariables=1
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

jsmorley wrote: April 30th, 2021, 11:03 am We need to solve the underlying need you have before we address the fact IfCondition can NEVER be used on a "meter", but must be used on a "measure".
Please tell me how to make the last element to work?

Code: Select all

IfCondition==(#UnixTime# > [MeasureInfoUnixTime])
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!Rain gauge counter]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!Precipitation counter]
Dynamic variables=1
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

MaestroSky wrote: April 30th, 2021, 11:15 am Please tell me how to make the last element to work?

Code: Select all

IfCondition==(#UnixTime# > [MeasureInfoUnixTime])
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!Rain gauge counter]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!Precipitation counter]
Dynamic variables=1
We will get there, but I WANT to understand what you are trying to do, and what values you want to compare first. There is almost nothing about that IfCondition that is right, but we will get to that. It will be easy to fix.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

OK, I get you :)
I'm pointing this out now:

Code: Select all

[Variables]
UnixTime=1619766794

[MeasureCurrentTime]
Measure=Time
DynamicVariables=1
UpdateDivider=-1

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
IfCondition=#UnixTime# > MeasureCurrentTime
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!RainmeterShowMeter MeterCount]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!RainmeterHideMeter MeterCount]
DynamicVariables=1
And thanks to you, I did it.
"Sensei, what is the truth?
It lies under your feet but you don't notice it or you don't want to see it"
Last edited by MaestroSky on April 30th, 2021, 11:31 am, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

MaestroSky wrote: April 30th, 2021, 11:26 am OK, I get you :)
I'm pointing this out now:

Code: Select all

[Variables]
UnixTime=1619766794

[MeasureCurrentTime]
Measure=Time
DynamicVariables=1
UpdateDivider=-1

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
DynamicVariables=1

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
IfCondition=#UnixTime# > MeasureInfoUnixTime
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!RainmeterShowMeter MeterCount]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!RainmeterHideMeter MeterCount]
DynamicVariables=1
And thanks to you, I did it.
"Sensei, what is the truth?
It lies under your feet but you don't notice it or you don't want to see it"
Ok, a few things I would point out.

1) You don't need DynamicVariables=1 on the [MeasureCurrentTime] measure.
2) I don't understand why you are setting UpdateDivider=-1 on [MeasureCurrentTime]. You do understand that that means it won't be the current time going forward, but a single static value when the skin is first run or refreshed.
3) DON'T use the !Rainmeter prefix on bangs. That was deprecated years ago. It should simply be [!HideMeter MeterIconEmpty] and so on.
MaestroSky
Posts: 33
Joined: April 20th, 2021, 4:15 pm

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by MaestroSky »

Sorry, I ran into Rainmeter in 2014 and started writing skins for it, but then I gave up. Now I am trying to resume this thanks to your parting words.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: IfCondition=[MeasureUnixTime] > [MeasureRealTime]

Post by jsmorley »

Your code as written is not going to work:

Code: Select all

[Variables]
UnixTime=1619766794

[MeasureCurrentTime]
Measure=Time
DynamicVariables=1
UpdateDivider=-1

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
DynamicVariables=1

[MeasureCurrentTimeToUnix]
Measure=Calc
Formula=([MeasureCurrentTime:Timestamp]-11644473600)
IfCondition=#UnixTime# > MeasureInfoUnixTime
IfTrueAction=[!RainmeterHideMeter MeterIconEmpty][!RainmeterShowMeter MeterIconFull][!RainmeterShowMeter MeterCount]
IfFalseAction=[!RainmeterHideMeter MeterIconFull][!RainmeterShowMeter MeterIconEmpty][!RainmeterHideMeter MeterCount]
DynamicVariables=1
This is a bit of a mess. You have TWO sections called [MeasureCurrentTimeToUnix], and in the second one, with the IfCondition on it, you are comparing the current time to a measure MeasureInfoUnixTime that doesn't exist. Not that it really matters since the second instance of [MeasureCurrentTimeToUnix] will never even be seen or executed, since it is a duplicate.