It is currently December 6th, 2022, 12:54 pm

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

Re: Weekdays and Time based Text change.

Post by foreverNoob »

balala wrote: November 17th, 2022, 6:46 pm Sorry, have no idea what you are talking about. What Emergency Only is?
I meant the Status Text. The one I'm switching from Online > Offline > Closed depending on the Day of the week and Time of they day. I need it to also consider the stat holiday and show Emergency Only.
User avatar
balala
Rainmeter Sage
Posts: 14765
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, 7:11 pm I meant the Status Text. The one I'm switching from Online > Offline > Closed depending on the Day of the week and Time of they day. I need it to also consider the stat holiday and show Emergency Only.
Ok, now understood this. But there still is a question, namely how you want to keep track of the holidays? I mean that when it's a holiday, how the skin will know this? To let it know, you have to add the date of the holiday as a variable. Or there is another approach?
For instance, on December 25th, the Christmas day, how we'll tell the skin this is a holiday? Having a variable, like Holiday=12/26 or whatever might be a solution, but this is exactly what I should know, how would you like to treat those holidays?
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, 7:48 pm Ok, now understood this. But there still is a question, namely how you want to keep track of the holidays? I mean that when it's a holiday, how the skin will know this? To let it know, you have to add the date of the holiday as a variable. Or there is another approach?
For instance, on December 25th, the Christmas day, how we'll tell the skin this is a holiday? Having a variable, like Holiday=12/26 or whatever might be a solution, but this is exactly what I should know, how would you like to treat those holidays?
I was asking about the same question to you lol. If variable works that I'm okay with that but then it means we have too many && operators in IfCondition. Can we make the skin iterate through a file where all holidays are listed with the status to show when the date matches? Please feel free to mention better option.
User avatar
balala
Rainmeter Sage
Posts: 14765
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, 7:55 pm Can we make the skin iterate through a file where all holidays are listed with the status to show when the date matches?
I don't say this is impossible, I rarely say something like this, but definitely is not easy. This is something which can easily be done in a real programming language, but in Rainmeter is a little bit more difficult. So, adding manually those variables is much easier. How many holidays do you want to use? There are 24 on the posted link. Manually adding 24 holidays can work.
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, 8:24 pm I don't say this is impossible, I rarely say something like this, but definitely is not easy. This is something which can easily be done in a real programming language, but in Rainmeter is a little bit more difficult. So, adding manually those variables is much easier. How many holidays do you want to use? There are 24 on the posted link. Manually adding 24 holidays can work.
You're correct, things would have been a lot more dynamic with an actual programming language. Perhaps Powershell support would be great! Anyway, If manually adding variables can make it work then, I'm happy with it for now. Let's go with all the holidays and once I understand how the conditions will works out I can modify it myself to change the amount of holidays.

Are you able to give me an example I can start with?

Your help is much appreciated.
User avatar
balala
Rainmeter Sage
Posts: 14765
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

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]
Just saw: I completely messed up the IfCondition4, duplicating the option name. This has to be removed, obviously: IfCondition4=IfCondition4=((Measure24Hr >= 17) || (Measure24Hr < 8) || (MeasureDayOfWeek >= 6)) should be IfCondition4=((Measure24Hr >= 17) || (Measure24Hr < 8) || (MeasureDayOfWeek >= 6)) in order all conditions to work.
:o Sorry, my bad I made this stupid mistake!!! :?

foreverNoob wrote: November 17th, 2022, 8:39 pm Are you able to give me an example I can start with?
Here is it:
  • In order to keep track of those holidays, we need some variables storing the dates of holidays, for instance this way:

    Code: Select all

    [Variables]
    Holiday1=10.31
    Holiday2=11.11
    Holiday3=12.25
    Holiday=0
    The last variable, Holiday (with no number) is a variable we'll need a little bit later, add it as well. As I suppose it's quite obvious, I added here only three holidays, but you can add further such variables if needed, so many as many are needed.
  • We need a measure which returns the date in the same format as the above variables. This measure will check if the current date coincides with any of the stored holiday dates, returning a variable accordingly. Add the following measure to your code:

    Code: Select all

    [MeasureHoliday]
    Measure=Time
    Format=%m.%d
    IfCondition=((#CURRENTSECTION#=#Holiday1#)||(#CURRENTSECTION#=#Holiday2#)||(#CURRENTSECTION#=#Holiday3#))
    IfTrueAction=[!SetVariable Holiday "1"][!UpdateMeasure "Measure24Hr"]
    IfFalseAction=[!SetVariable Holiday "0"][!UpdateMeasure "Measure24Hr"]
    If you're using more than three variables storing holiday dates, you obviously have to add further (#CURRENTSECTION#=#HolidayXX#) conditions to the IfCondition option, so many conditions as many holidays have you stored into the [Variables] section). I hope you got the idea how to do this (let me know if you didn't).
  • Finally modify the IfConditions of the [Measure24Hr] measure, to get into account the value of the newly added Holiday variable as well. Replace the existing measure with the following one:

    Code: Select all

    [Measure24Hr]
    Measure=Time
    Format=%#H
    IfCondition=(#Holiday#=1)
    IfTrueAction=[!SetOption MeterSupportStatus Text "Emergency Only"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus][!Redraw]
    IfCondition=((Measure24Hr >= 8) && (Measure24Hr < 12) && (MeasureDayOfWeek < 6) && (#Holiday#=0))
    IfTrueAction=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus][!Redraw]
    IfCondition2=((Measure24Hr >= 12) && (Measure24Hr < 13) && (MeasureDayOfWeek < 6) && (#Holiday#=0))
    IfTrueAction2=[!SetOption MeterSupportStatus Text "Offline!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus][!Redraw]
    IfCondition3=((Measure24Hr >= 13) && (Measure24Hr < 17) && (MeasureDayOfWeek < 6) && (#Holiday#=0))
    IfTrueAction3=[!SetOption MeterSupportStatus Text "Online!"][!SetVariable statusColor "0,255,0,255"][!UpdateMeter MeterSupportStatus][!Redraw]
    IfCondition4=(((Measure24Hr >= 17) || (Measure24Hr < 8) || (MeasureDayOfWeek >= 6)) && (#Holiday#=0))
    IfTrueAction4=[!SetOption MeterSupportStatus Text "Closed!"][!SetVariable statusColor "255,0,0,255"][!UpdateMeter MeterSupportStatus][!Redraw]
    DynamicVariables=1
    When replacing the measure take care NOT TO FORGET the DynamicVariables=1 option, which has not been present previously, because the measure won't work without it.
And I add one more simple explanation to the above added [MeasureHoliday] measure, or in fact to its IfCondition. The measure is returning a date in the Month.Day form. This is in fact a decimal number, the integer part of it is the month and the decimal part is the day. This value is treated accordingly by the IfCondition and this is why we can use it to check the match of current date with the date of holidays (note that IfConditions work ONLY with numeric values).
Please try out the above solution and let me know if you could get it to work.
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

You're brilliant Sir! :bow:

I'll report back with the update once I finish this.
User avatar
balala
Rainmeter Sage
Posts: 14765
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 19th, 2022, 2:37 am You're brilliant Sir! :bow:
I am not at all. Many people say I am not.
foreverNoob wrote: November 19th, 2022, 2:37 am I'll report back with the update once I finish this.
Please do so. Am curious...
foreverNoob
Posts: 11
Joined: November 16th, 2022, 4:39 pm

Re: Weekdays and Time based Text change.

Post by foreverNoob »

balala wrote: November 19th, 2022, 6:36 pm Please do so. Am curious...
I noticed the first two IfConditions have no number to make them unique. Wouldn't that ignore the 2nd one? or is that something the DynamicVariable=1 will take care of? I added couple more holidays and it seems to be working fine.
User avatar
balala
Rainmeter Sage
Posts: 14765
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Weekdays and Time based Text change.

Post by balala »

foreverNoob wrote: November 20th, 2022, 8:36 pm I noticed the first two IfConditions have no number to make them unique. Wouldn't that ignore the 2nd one?
:? Right. My bad. Again. :?
Obviously, you have to number the IfConditions (and the appropriate IfTrueActions) in order. So, replace the second occurence of IfCondition and IfTrueAction with IfCondition2 and IfTrueAction2, the old IfCondition2 and IfTrueAction2 with IfCondition3 and IfTrueAction3 and so on.
Sorry for this extremely stupid mistake. A copy / paste problem.
foreverNoob wrote: November 20th, 2022, 8:36 pm or is that something the DynamicVariable=1 will take care of?
The DynamicVariables=1 option is needed because the measure uses a variable (#Holiday#), which is dynamically set with !SetVariable bangs into the IfTrueAction and IfFalseAction options of the [MeasureHoliday] measure. Doesn't matter what you do, Rainmeter ALWAYS ignores the second occurrence of options, sections, variables.
foreverNoob wrote: November 20th, 2022, 8:36 pm I added couple more holidays and it seems to be working fine.
Yep, but this only because you didn't try the code from Monday to Friday, between 8AM and 12PM, when there is no holiday set. These are the conditions set into the second not-numbered IfCondition, which is ignored by Rainmeter. But please re-number the options, as explained above.

Sorry again for this mistake.