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

Weekdays and Time based Text change.

Get help with creating, editing & fixing problems with skins
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Weekdays and Time based Text change.

Post by foreverNoob »

Hello,

I'm working on making a skin for my company where it shows when is our service is online and when it's not depending on the schedule we have. It's basically depends on our schedule. I'm able to create this using IfCondition but it's not going to work when more conditions are introduced. This is what I have as of now.

Code: Select all

[MeasureDayOfWeek]
Measure=Time
Format=%u

[Measure24Hr]
Measure=Time
Format=%#H
IfCondition=((Measure24Hr >= 8) && (Measure24Hr < 12) && (MeasureDayOfWeek < 6))
IfTrueAction=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfFalseAction=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]

IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13)) && (MeasureDayOfWeek < 6))
IfTrueAction2=[!SetOption MeterSupportStatus Text "Offline!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
IfFalseAction2=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]

IfCondition3=((Measure24Hr >= 13) && (Measure24Hr < 17) && (MeasureDayOfWeek < 6))
IfTrueAction3=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfFalseAction3=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]

IfCondition4=((Measure24Hr >= 17) || (Measure24Hr = 0))
IfTrueAction4=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
It's broken! I'd like it to Change the text as following:
  • 8AM to 11:59AM - Online
  • 12PM to 12:59PM - Offline
  • 1PM to 4:59PM - Online
  • Saturday & Sunday Closed
I'm already struggling after introducing weekends into IfConditions and the status label closed. I need to make follow an entire year schedule that we have including stat holidays. What's the best way to achieve this?

Please and Thank you! :welcome:
jasonvertez
Posts: 6
Joined: October 28th, 2022, 10:13 pm

Re: Weekdays and Time based Text change.

Post by jasonvertez »

Hi, can you post more context for the whole code? I actually just posted something similar to this question a few minutes ago, except referring to seconds.

Don't forget to add

Code: Select all

[!UpdateMeter *][!Redraw]
bang after updating meter.

Ex:

Code: Select all

[!UpdateMeter MeterSupportStatus][!Redraw]
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

jasonvertez wrote: November 16th, 2022, 6:04 pm Hi, can you post more context for the whole code? I actually just posted something similar to this question a few minutes ago, except referring to seconds.

Don't forget to add

Code: Select all

[!UpdateMeter *][!Redraw]
bang after updating meter.

Ex:

Code: Select all

[!UpdateMeter MeterSupportStatus][!Redraw]
There's a lot in my .ini. What do you need to see?
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 16th, 2022, 6:13 pm There's a lot in my .ini. What do you need to see?
Nothing, the posted code is completely enough. There are a few logical mistakes in the IfConditions:
  • If you want to set the same things (in this case the Text option of the [MeterSupportStatus] meter and the statusColor variable), it's not recommended to use both, IfTrueAction and IfFalseAction options on all IfConditions. Instead work only with IfTrueAction. If the conditions are set correctly only one of them is true at a time and the appropriate IfTrueAction is executed, which sets a well-defined value for the Text option and a well-defined value for the variable. If you have IfTrueAction and IfFalseActions on all IfConditions, there applies always one IfTrueAction and more IfFalseActions. So what value will get the Text option and what one the variable? This is why in such cases using only IfTrueActions is a much better idea.
  • The parenthesis in the IfCondition2 option are not in pair. Accordingly none of the IfTrueAction2 and IfFalseAction2 options is executed. If you take a look there are more parenthesis closed, than opened: IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13)) && (MeasureDayOfWeek < 6)). Remove the not-needed parentheses: IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13) && (MeasureDayOfWeek < 6)).
  • The IfCondition4 is not complete. This is what you have: IfCondition4=((Measure24Hr >= 17) || (Measure24Hr = 0)). But with this option which condition is true before 8? None. So, I assume this condition should be IfCondition4=((Measure24Hr >= 17) || (Measure24Hr < 8)).
  • In the condition list you didn't say anything about what should happen between 5PM and 8AM, but you did include this into the IfCondition4.
  • The IfConditions don't include what should happen Saturday and Sunday, but you did post this into the condition list above.
Accordingly the IfConditions should look like this (might look other ways as well, this is just my example):

Code: Select all

[Measure24Hr]
Measure=Time
Format=%#H
IfCondition=((Measure24Hr >= 8) && (Measure24Hr < 12) && (MeasureDayOfWeek < 6))
IfTrueAction=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13) && (MeasureDayOfWeek < 6))
IfTrueAction2=[!SetOption MeterSupportStatus Text "Offline!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition3=((Measure24Hr >= 13) && (Measure24Hr < 17) && (MeasureDayOfWeek < 6))
IfTrueAction3=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition4=IfCondition4=((Measure24Hr >= 17) || (Measure24Hr < 8) || (MeasureDayOfWeek >= 6))
IfTrueAction4=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

balala wrote: November 16th, 2022, 8:06 pm

Code: Select all

[Measure24Hr]
Measure=Time
Format=%#H
IfCondition=((Measure24Hr >= 8) && (Measure24Hr < 12) && (MeasureDayOfWeek < 6))
IfTrueAction=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13) && (MeasureDayOfWeek < 6))
IfTrueAction2=[!SetOption MeterSupportStatus Text "Offline!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition3=((Measure24Hr >= 13) && (Measure24Hr < 17) && (MeasureDayOfWeek < 6))
IfTrueAction3=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus]
IfCondition4=IfCondition4=((Measure24Hr >= 17) || (Measure24Hr < 8) || (MeasureDayOfWeek >= 6))
IfTrueAction4=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus]
Thank you for my error rectification. It seems to be working perfectly now. The last condition was the big culprit.

Now, I'm hoping the status can change depending on the Stat Holidays as well and not just for the weekends. I understand it's a bigger task and I'm willing to invest time in this if it can be achieved. Will you able to direct me into right direction? What's the best way to achieve this? I believe using && operators in IfConditions will make it real messy. :vomit:
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 16th, 2022, 8:42 pm Now, I'm hoping the status can change depending on the Stat Holidays as well and not just for the weekends. I understand it's a bigger task and I'm willing to invest time in this if it can be achieved. Will you able to direct me into right direction?
How are you keeping track of those holidays? Do you have their dates in some variables? Or are using another method?
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

balala wrote: November 16th, 2022, 9:25 pm How are you keeping track of those holidays? Do you have their dates in some variables? Or are using another method?
I'm referring this: https://www.statutoryholidays.com/2022.php
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 16th, 2022, 11:06 pm I'm referring this: https://www.statutoryholidays.com/2022.php
Yep, but how do you want to use them? Do you want to get them from the site, or you gonna enter them manually into the skin? Second case is much easier to handle.
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

balala wrote: November 17th, 2022, 4:05 pm Yep, but how do you want to use them? Do you want to get them from the site, or you gonna enter them manually into the skin? Second case is much easier to handle.
I'm hoping to change the status to Emergency Only if the date of the month matches. So, this will somehow has to be part of the conditions.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 17th, 2022, 4:59 pm I'm hoping to change the status to Emergency Only if the date of the month matches. So, this will somehow has to be part of the conditions.
Sorry, have no idea what you are talking about. What Emergency Only is?