It is currently August 16th, 2022, 5:03 am

[solved] help to simplify a bunch of IfCondition

Get help with creating, editing & fixing problems with skins
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4806
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: help to simplify a bunch of IfCondition

Post by eclectic-tech »

Instead of using the date number to test, use the TimeStamp of today, subtract 1 day of seconds (86400) for yesterday, and add 86400 seconds for tomorrow.

Read more about working with TimeStamps here...

Sample code showing values for yesterday, today, and tomorrow.

Code: Select all

; ========= Skin Settings ==========
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
Group=#RootConfig#

; ========= Measures ==========
[MeasureToday]
Measure=Time
Format=%#c
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes

[MeasureYesterday]
Measure=Time
Format=%#c
TimeStamp=([MeasureToday:TimeStamp]-86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


[MeasureTomorrow]
Measure=Time
Format=%#c
TimeStamp=([MeasureToday:TimeStamp]+86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


; ========= Meter Styles ==========



; ========= Meters ==========
[MeterYesterday]
Meter=String
MeasureName=MeasureYesterday
X=([MeterTomorrow:W])
StringAlign=Right
Text="    Yesterday was: %1"
SolidColor=0,0,0,1
DynamicVariables=1

[MeterToday]
Meter=String
MeasureName=MeasureToday
X=([MeterTomorrow:W])
StringAlign=Right
Text="              Today is: %1"
Y=R
SolidColor=0,0,0,1
DynamicVariables=1

[MeterTomorrow]
Meter=String
MeasureName=MeasureTomorrow
X=([MeterTomorrow:W])
StringAlign=Right
Text=Tomorrow will be: %1
Y=R
SolidColor=0,0,0,1
DynamicVariables=1
3days.png
By changing the Time measure Format option you can get any date/time details you want as the values of the measures for today, yesterday, or tomorrow.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 14465
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: help to simplify a bunch of IfCondition

Post by balala »

To be honest I just read the post, but at least as far as I can say, there is no need to create conditions. Don't complicate things. Would be nice you to post the whole code of your skin, maybe there is a simply way to achieve what you want.
So waiting for the whole code...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4806
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: help to simplify a bunch of IfCondition

Post by eclectic-tech »

Seeing all of your code would make it easier to help.

But you misunderstood my suggestion:
Simply use those 3 measures to determine yesterday, today, and tomorrow.

This way completely eliminates any need to test all the days of the month in IfConditions tests.

Here is my code with days as measure values and a combined string meter that will give you the desired result:

Code: Select all

; ========= Metadata ==========
[Metadata]
Name=
Author=
Information=
; BY=attribution / SA=share-alike / ND=no-derivatives / NC=non-commercial
License=CC BY-SA-NC 3.0
Version=

; ========= Variables ==========
[Variables]


; ========= Skin Settings ==========
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
Group=#RootConfig#

; ========= Measures ==========
[MeasureToday]
Measure=Time
Format=%#d
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes

[MeasureYesterday]
Measure=Time
Format=%#d
TimeStamp=([MeasureToday:TimeStamp]-86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


[MeasureTomorrow]
Measure=Time
Format=%#d
TimeStamp=([MeasureToday:TimeStamp]+86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


; ========= Meter Styles ==========



; ========= Meters ==========
[Number]
Meter=String
MeasureName=MeasureYesterday
MeasureName2=MeasureToday
MeasureName3=MeasureTomorrow
FontColor=220,220,220
FontSize=18
Text=%1 %2 %3
InlinePattern=[MeasureToday]
InlineSetting=Color | 255,0,0
Antialias=1
X=30
StringAlign=Center
3daysN.png
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Re: help to simplify a bunch of IfCondition

Post by death.crafter »

carlitosbahia wrote: January 4th, 2022, 6:29 am so questions :
1) how do i need to use something like

Code: Select all

!SetVariable variablename measurename+1
? ( being 4 today that i get with the measure so get 5 for tomorrow , only the 5 , not the full Format=%#c )
2) in

Code: Select all

!SetOption metername InlinePattern  XYZ
, how i add a space before and after the XYZ string ( reason to use space in my first post )
Answering your questions,
  1. Code: Select all

    ; the paranthesis are required where arithmetic operations are done
    ; [SectionVariable] is used to get the string value of a measure in a line of code, use a colon(:) after it to force numeric value.
    ; In most cases tho, as in your case, both string and numeric values are numeric, so no need of colon postfix.
    ; ===============================
    SomeAction=[!SetVariable VariableName "([MeasureName]+1)"]
    ; ===============================
    
  2. Code: Select all

    ; you can use quotes to use spaces at start or end, but while setting an option's value, starting and ending 
    ; white spaces are ignored
    ; but it's a regex pattern and we could do it as
    ; ===============================
    SomeAction=[!SetOption metername InlinePattern  "\sXYZ\s"]
    ; ===============================
    ; since \s denotes white space character
    
Apart from above things see eclectic-tech's code. Another illustration of the same would be:

Code: Select all

; ========= Metadata ==========
[Metadata]
Name=
Author=
Information=
; BY=attribution / SA=share-alike / ND=no-derivatives / NC=non-commercial
License=CC BY-SA-NC 3.0
Version=

; ========= Variables ==========
[Variables]


; ========= Skin Settings ==========
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
Group=#RootConfig#

; ========= Measures ==========
[MeasureToday]
Measure=Time
Format=%A
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes

[MeasureYesterday]
Measure=Time
Format=%A
TimeStamp=([MeasureToday:TimeStamp]-86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


[MeasureTomorrow]
Measure=Time
Format=%A
TimeStamp=([MeasureToday:TimeStamp]+86400)
DynamicVariables=1
; Documentation: Format Codes https://docs.rainmeter.net/manual-beta/measures/time/#FormatCodes


; ========= Meter Styles ==========



; ========= Meters ==========
[Number]
Meter=String
MeasureName=MeasureYesterday
MeasureName2=MeasureToday
MeasureName3=MeasureTomorrow
FontFace=Segoe Script
FontColor=200,200,200
FontSize=18
Text=%1 %2 %3
InlinePattern=[MeasureToday:EscapeRegExp]
InlineSetting=Color | 255,255,255
InlinePattern2=[MeasureToday:EscapeRegExp]
InlineSetting2=Shadow | 0 | 0 | 5 | 255,255,255
Antialias=1
Padding=5,5,5,5
Screenshot 2022-01-04 223126.png
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 14465
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: help to simplify a bunch of IfCondition

Post by balala »

carlitosbahia wrote: January 4th, 2022, 5:02 pm yes, i could see that what i want to do with the months ( previous and next month, not month of previous and next day ) is probably not what most people would want to do in this type of skin :D
but also would be nice to learn for future skins how i can do that simple math with some variables ( forget about being dates for a second , just any variables ) using a !setvariable inside a IfTrueAction
Apart from the next posts here is an example of code, which does what is required without setting those variables. Yep, I saw death.crafter's code, however if I'm not mistaken, even if it does work for weekdays and dates, it doesn't for month. The months have the problem of variable lengths. How many days are you adding / extracting from the time stamp of a Time measure returning current day, to get the name of previous / next month, no matter of date? What I mean is that for instance on Jan 1 you have to add 31 days (31 x 86400 seconds) to get the name of next month (February), but if you add the same 31 days on Jan 31, you get March instead of February, because February has only 28 (or in leap years 29) days, so adding 31 days is too much in such a case. To fix this, you have to add a variable number of days. See the TimeStamp option of the [MeasurePrevMonth] and [MeasureNextMonth] measures of the below code.
I didn't remove so far all those IfCondition and IfTrueAction options from the Time measures, just commented them out, to let you see how much easier and shorter is such a code. But in fact they are not needed anymore, you can freely remove them. In this approach there is also not needed to set too complicated InlinePatters. They are handled "on fly" in the String meters themselves ([Day], [Number] and [Month]).
If you want, please test the code and let me know what you think.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!Move "(#WORKAREAWIDTH#-435-20)" 20]
AccurateText=1

[Metadata]
Name=YetAnotherDateTimeSkin BeforeAFter
Author=CarlitosBahia
Information=First try to make a date/time skin - added Before After
Version=1.0.0
License=Whatever

[Variables]
FontName=Dealerplate California
FontClockSize=90
FontAMPMSize=60
FontMainSize=20
FontFullColor=255,255,255,255
FontDimmedColor=255,255,255,80
Dia=""
DiaMenos=""
DiaMas=""
Numero=""
NumeroMenos=""
NumeroMas=""
Mes=""
Mesmenos=""
MesMas=""

[MeterBack]
Meter=Shape
Shape=Rectangle 0,0,435,240,20 | Fill Color 252,255,225,50 | StrokeWidth 0

; =====> CLOCK
[MeasureClock]
Measure=Time
Format=%I %M

[MeterClock]
Meter=String
MeasureName=MeasureClock
FontFace=#FontName#
FontColor=#FontFullColor#
FontSize=#FontClockSize#
StringAlign=Right
AntiAlias=1
X=235
Y=0

; =====> SECONDS
[MeasureSecs]
Measure=Time
Format=%S

[MeterSecs]
Meter=String
MeasureName=MeasureSecs
FontFace=#FontName#
FontColor=#FontFullColor#
FontSize=#FontAMPMSize#
StringAlign=Center
AntiAlias=1
X=50r
Y=23r

; =====> AM/PM
[MeasureAMPM]
Measure=Time
Format=%p

[MeterAMPM]
Meter=String
MeasureName=MeasureAMPM
FontFace=#FontName#
FontColor=#FontFullColor#
FontSize=#FontAMPMSize#
StringAlign=Center
AntiAlias=1
X=80r
Y=0r

; =====> SUN-SAT
[MeasureDay]
Measure=Time
Format=%A
;IfCondition=MeasureDay = 1
;IfTrueAction=[!SetOption Day InlinePattern MONDAY][!SetVariable DiaMenos SUNDAY][!SetVariable Dia MONDAY][!SetVariable DiaMas TUESDAY] 
;IfCondition2=MeasureDay = 2
;IfTrueAction2=[!SetOption Day InlinePattern TUESDAY][!SetVariable DiaMenos MONDAY][!SetVariable Dia TUESDAY][!SetVariable DiaMas WEDNESDAY]
;IfCondition3=MeasureDay = 3
;IfTrueAction3=[!SetOption Day InlinePattern WEDNESDAY][!SetVariable DiaMenos TUESDAY][!SetVariable Dia WEDNESDAY][!SetVariable DiaMas THURSDAY] 
;IfCondition4=MeasureDay = 4
;IfTrueAction4=[!SetOption Day InlinePattern THURSDAY][!SetVariable DiaMenos WEDNESDAY][!SetVariable Dia THURSDAY][!SetVariable DiaMas FRIDAY] 
;IfCondition5=MeasureDay = 5
;IfTrueAction5=[!SetOption Day InlinePattern FRIDAY][!SetVariable DiaMenos THURSDAY][!SetVariable Dia FRIDAY][!SetVariable DiaMas SATURDAY] 
;IfCondition6=MeasureDay = 6
;IfTrueAction6=[!SetOption Day InlinePattern SATURDAY][!SetVariable DiaMenos FRIDAY][!SetVariable Dia SATURDAY][!SetVariable DiaMas SUNDAY] 
;IfCondition7=(MeasureDay = 7)
;IfTrueAction7=[!SetOption Day InlinePattern SUNDAY][!SetVariable DiaMenos SATURDAY][!SetVariable Dia SUNDAY][!SetVariable DiaMas MONDAY]

[MeasurePrevDay]
Measure=Time
Format=%A
TimeStamp=([MeasureNumber:TimeStamp]-86400)
DynamicVariables=1

[MeasureNextDay]
Measure=Time
Format=%A
TimeStamp=([MeasureNumber:TimeStamp]+86400)
DynamicVariables=1

[Day]
Meter=String
MeasureName=MeasurePrevDay
MeasureName2=MeasureDay
MeasureName3=MeasureNextDay
FontFace=#FontName#
FontSize=#FontMainSize#
FontColor=#FontDimmedColor#
Text=%1 %2 %3
InlineSetting=Color | #FontFullColor#
InlinePattern=[MeasureDay]
Antialias=1
StringAlign=Center
X=215
Y=5R
DynamicVariables=1

; =====> 1-31

[MeasureNumber]
Measure=Time
Format=%#d
;IfCondition=MeasureNumber = 1
;IfTrueAction=[!SetOption Number InlinePattern " 1 "][!SetVariable NumeroMenos 31][!SetVariable Numero 1][!SetVariable NumeroMas 2]
;IfCondition2=MeasureNumber = 2
;IfTrueAction2=[!SetOption Number InlinePattern " 2 "][!SetVariable NumeroMenos 1][!SetVariable Numero 2][!SetVariable NumeroMas 3]
;IfCondition3=MeasureNumber = 3
;IfTrueAction3=[!SetOption Number InlinePattern " 3 "][!SetVariable NumeroMenos 2][!SetVariable Numero 3][!SetVariable NumeroMas 4]
;IfCondition4=MeasureNumber = 4
;IfTrueAction4=[!SetOption Number InlinePattern " 4 "][!SetVariable NumeroMenos 3][!SetVariable Numero 4][!SetVariable NumeroMas 5]
;IfCondition5=MeasureNumber = 5
;IfTrueAction5=[!SetOption Number InlinePattern " 5 "][!SetVariable NumeroMenos 4][!SetVariable Numero 5][!SetVariable NumeroMas 6]
;IfCondition6=MeasureNumber = 6
;IfTrueAction6=[!SetOption Number InlinePattern " 6 "][!SetVariable NumeroMenos 5][!SetVariable Numero 6][!SetVariable NumeroMas 7]
;IfCondition7=MeasureNumber = 7
;IfTrueAction7=[!SetOption Number InlinePattern " 7 "][!SetVariable NumeroMenos 6][!SetVariable Numero 7][!SetVariable NumeroMas 8]
;IfCondition8=MeasureNumber = 8
;IfTrueAction8=[!SetOption Number InlinePattern " 8 "][!SetVariable NumeroMenos 7][!SetVariable Numero 8][!SetVariable NumeroMas 9]
;IfCondition9=MeasureNumber = 9
;IfTrueAction9=[!SetOption Number InlinePattern " 9 "][!SetVariable NumeroMenos 8][!SetVariable Numero 9][!SetVariable NumeroMas 10]
;IfCondition10=MeasureNumber = 10
;IfTrueAction10=[!SetOption Number InlinePattern " 10 "][!SetVariable NumeroMenos 9][!SetVariable Numero 10][!SetVariable NumeroMas 11]
;IfCondition11=MeasureNumber = 11
;IfTrueAction11=[!SetOption Number InlinePattern " 11 "][!SetVariable NumeroMenos 10][!SetVariable Numero 11][!SetVariable NumeroMas 12]
;IfCondition12=MeasureNumber = 12
;IfTrueAction12=[!SetOption Number InlinePattern " 12 "][!SetVariable NumeroMenos 11][!SetVariable Numero 12][!SetVariable NumeroMas 13]
;IfCondition13=MeasureNumber = 13
;IfTrueAction13=[!SetOption Number InlinePattern " 13 "][!SetVariable NumeroMenos 12][!SetVariable Numero 13][!SetVariable NumeroMas 14]
;IfCondition14=MeasureNumber = 14
;IfTrueAction14=[!SetOption Number InlinePattern " 14 "][!SetVariable NumeroMenos 13][!SetVariable Numero 14][!SetVariable NumeroMas 15]
;IfCondition15=MeasureNumber = 15
;IfTrueAction15=[!SetOption Number InlinePattern " 15 "][!SetVariable NumeroMenos 14][!SetVariable Numero 15][!SetVariable NumeroMas 16]
;IfCondition16=MeasureNumber = 16
;IfTrueAction16=[!SetOption Number InlinePattern " 16 "][!SetVariable NumeroMenos 15][!SetVariable Numero 16][!SetVariable NumeroMas 17]
;IfCondition17=MeasureNumber = 17
;IfTrueAction17=[!SetOption Number InlinePattern " 17 "][!SetVariable NumeroMenos 16][!SetVariable Numero 17][!SetVariable NumeroMas 18]
;IfCondition18=MeasureNumber = 18
;IfTrueAction18=[!SetOption Number InlinePattern " 18 "][!SetVariable NumeroMenos 17][!SetVariable Numero 18][!SetVariable NumeroMas 19]
;IfCondition19=MeasureNumber = 19
;IfTrueAction19=[!SetOption Number InlinePattern " 19 "][!SetVariable NumeroMenos 18][!SetVariable Numero 19][!SetVariable NumeroMas 20]
;IfCondition20=MeasureNumber = 20
;IfTrueAction20=[!SetOption Number InlinePattern " 20 "][!SetVariable NumeroMenos 19][!SetVariable Numero 20][!SetVariable NumeroMas 21]
;IfCondition21=MeasureNumber = 21
;IfTrueAction21=[!SetOption Number InlinePattern " 21 "][!SetVariable NumeroMenos 20][!SetVariable Numero 21][!SetVariable NumeroMas 22]
;IfCondition22=MeasureNumber = 22
;IfTrueAction22=[!SetOption Number InlinePattern " 22 "][!SetVariable NumeroMenos 21][!SetVariable Numero 22][!SetVariable NumeroMas 23]
;IfCondition23=MeasureNumber = 23
;IfTrueAction23=[!SetOption Number InlinePattern " 23 "][!SetVariable NumeroMenos 22][!SetVariable Numero 23][!SetVariable NumeroMas 24]
;IfCondition24=MeasureNumber = 24
;IfTrueAction24=[!SetOption Number InlinePattern " 24 "][!SetVariable NumeroMenos 23][!SetVariable Numero 24][!SetVariable NumeroMas 25]
;IfCondition25=MeasureNumber = 25
;IfTrueAction25=[!SetOption Number InlinePattern " 25 "][!SetVariable NumeroMenos 24][!SetVariable Numero 25][!SetVariable NumeroMas 26]
;IfCondition26=MeasureNumber = 26
;IfTrueAction26=[!SetOption Number InlinePattern " 26 "][!SetVariable NumeroMenos 25][!SetVariable Numero 26][!SetVariable NumeroMas 27]
;IfCondition27=MeasureNumber = 27
;IfTrueAction27=[!SetOption Number InlinePattern " 27 "][!SetVariable NumeroMenos 26][!SetVariable Numero 27][!SetVariable NumeroMas 28]
;IfCondition28=MeasureNumber = 28
;IfTrueAction28=[!SetOption Number InlinePattern " 28 "][!SetVariable NumeroMenos 27][!SetVariable Numero 28][!SetVariable NumeroMas 29]
;IfCondition29=MeasureNumber = 29
;IfTrueAction29=[!SetOption Number InlinePattern " 29 "][!SetVariable NumeroMenos 28][!SetVariable Numero 29][!SetVariable NumeroMas 30]
;IfCondition30=MeasureNumber = 30
;IfTrueAction30=[!SetOption Number InlinePattern " 30 "][!SetVariable NumeroMenos 29][!SetVariable Numero 30][!SetVariable NumeroMas 31]
;IfCondition31=MeasureNumber = 31
;IfTrueAction31=[!SetOption Number InlinePattern " 31 "][!SetVariable NumeroMenos 30][!SetVariable Numero 31][!SetVariable NumeroMas 1]

[MeasureYesterday]
Measure=Time
Format=%#d
TimeStamp=([MeasureNumber:TimeStamp]-86400)
DynamicVariables=1

[MeasureTomorrow]
Measure=Time
Format=%#d
TimeStamp=([MeasureNumber:TimeStamp]+86400)
DynamicVariables=1

[Number]
Meter=String
MeasureName=MeasureYesterday
MeasureName2=MeasureNumber
MeasureName3=MeasureTomorrow
FontFace=#FontName#
FontColor=#FontDimmedColor#
FontSize=#FontMainSize#
Text=%1 %2 %3
InlineSetting=Color | #FontFullColor#
InlinePattern=[MeasureNumber]
Antialias=1
StringAlign=Center
X=215
Y=0R
DynamicVariables=1

; =====> JAN-DEC 
[MeasureMonth]
Measure=Time
Format=%b
;IfMatch=Jan
;IfMatchAction=[!SetOption Month InlinePattern JANUARY][!SetVariable MesMenos DECEMBER][!SetVariable Mes JANUARY][!SetVariable MesMas FEBRAURY]
;IfMatch2=Feb
;IfMatchAction2=[!SetOption Month InlinePattern FEBRAURY][!SetVariable MesMenos JANUARY][!SetVariable Mes FEBRAURY][!SetVariable MesMas MARCH]
;IfMatch3=Mar
;IfMatchAction3=[!SetOption Month InlinePattern MARCH][!SetVariable MesMenos FEBRAURY][!SetVariable Mes MARCH][!SetVariable MesMas APRIL] 
;IfMatch4=Apr
;IfMatchAction4=[!SetOption Month InlinePattern APRIL][!SetVariable MesMenos MARCH][!SetVariable Mes APRIL][!SetVariable MesMas MAY] 
;IfMatch5=May
;IfMatchAction5=[!SetOption Month InlinePattern MAY][!SetVariable MesMenos APRIL][!SetVariable Mes MAY][!SetVariable MesMas JUNE] 
;IfMatch6=Jun
;IfMatchAction6=[!SetOption Month InlinePattern JUNE][!SetVariable MesMenos MAY][!SetVariable Mes JUNE][!SetVariable MesMas JULY]
;IfMatch7=July
;IfMatchAction7=[!SetOption Month InlinePattern JULY][!SetVariable MesMenos JUNE][!SetVariable Mes JULY][!SetVariable MesMas AUGUST]
;IfMatch8=Aug
;IfMatchAction8=[!SetOption Month InlinePattern AUGUST][!SetVariable MesMenos JULY][!SetVariable Mes AUGUST][!SetVariable MesMas SEPTEMBER]
;IfMatch9=Sept
;IfMatchAction9=[!SetOption Month InlinePattern SEPTEMBER][!SetVariable MesMenos AUGUST][!SetVariable Mes SEPTEMBER][!SetVariable MesMas OCTOBER]
;IfMatch10=Oct
;IfMatchAction10=[!SetOption Month InlinePattern OCTOBER][!SetVariable MesMenos SEPTEMBER][!SetVariable Mes OCTOBER][!SetVariable MesMas NOVEMBER]
;IfMatch11=Nov
;IfMatchAction11=[!SetOption Month InlinePattern NOVEMBER][!SetVariable MesMenos OCTOBER][!SetVariable Mes NOVEMBER][!SetVariable MesMas DECEMBER]
;IfMatch12=Dic
;IfMatchAction12=[!SetOption Month InlinePattern DECEMBER][!SetVariable MesMenos NOVEMBER][!SetVariable Mes DECEMBER][!SetVariable MesMas JANUARY]

[MeasurePrevMonth]
Measure=Time
Format=%b
TimeStamp=([MeasureNumber:TimeStamp]-31*86400+(([MeasureNumber]<5)*10*86400))
DynamicVariables=1

[MeasureNextMonth]
Measure=Time
Format=%b
TimeStamp=([MeasureNumber:TimeStamp]+31*86400-(([MeasureNumber]>25)*10*86400))
DynamicVariables=1

[Month]
Meter=String
MeasureName=MeasurePrevMonth
MeasureName2=MeasureMonth
MeasureName3=MeasureNextMonth
FontFace=#FontName#
FontColor=#FontDimmedColor#
FontSize=#FontMainSize#
Text=%1 %2 %3
InlineSetting=Color | #FontFullColor#
InlinePattern=[MeasureMonth]
Antialias=1
StringAlign=Center
X=215
Y=0R
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 14465
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: help to simplify a bunch of IfCondition

Post by balala »

carlitosbahia wrote: January 4th, 2022, 7:49 pm i assume that is rainmeter way to say If [MeasureNumber]<5 then make that 1 , else then make it 0 ?
Right. In this case for instance, when day is less than 5 (so on 1st - 4th of month), you extract 31 days (31x86400 seconds) and add 10 days (10x86400 seconds). This means that for the first 4 days of month are extracted only 31-10 = 21 days, which ensures you that you get the previous month, not the one before. For dates after 5th of month, extracting 31 days is perfect, you get the previous month in every case.
In fact the above formula used in the TimeStamp option should have been TimeStamp=([MeasureNumber:TimeStamp]-31*86400+((([MeasureNumber]<5)?1:0)*10*86400)), I just simplified a little bit, omitting the not-needed part of the formula. But I suppose you got the essence (congratulations for this, good job :thumbup: ).
User avatar
balala
Rainmeter Sage
Posts: 14465
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: help to simplify a bunch of IfCondition

Post by balala »

carlitosbahia wrote: January 4th, 2022, 8:46 pm now time to torture myself with the spanish version ( hope i don't have to add conditions again, lol )
Don't add them back. With the approach I posted above it'll work.
Just a side note: you don't have to translate the values returned by Time measures. These measures are able to return the string in any language (Spanish for instance). For this you only have to add a FormatLocale=es-ES option to the measures which you want too get the result in Spanish (or if you want another dialect find the proper language identifier here).
User avatar
death.crafter
Rainmeter Sage
Posts: 1370
Joined: April 24th, 2021, 8:13 pm

Re: help to simplify a bunch of IfCondition

Post by death.crafter »

carlitosbahia wrote: January 4th, 2022, 9:41 pm well, that part was easier than expected, went smooth :great:
learned some useful things on the way so even better :thumbup:


gonna search for a new idea and leave this skin rest for now :D , just for future reference or whatever this is the final result ( black/white , eng/esp )
https://www.mediafire.com/file/vjq31zb0uyup6xq/YADTS_BeforeAfter_V2.7z/file
Congrats on your first skin...
P.S. Rainmeter is like a webpage, just meters instead of elements lol
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 14465
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: help to simplify a bunch of IfCondition

Post by balala »

carlitosbahia wrote: January 4th, 2022, 9:41 pm well, that part was easier than expected, went smooth :great:
Which part? Translating strings returned by Time measures or fixing the coloring problem of your skin?
In any case, I'm glad if you got it working as expected.
carlitosbahia wrote: January 4th, 2022, 9:41 pm learned some useful things on the way so even better :thumbup:
There is always something to learn...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4806
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: [solved] help to simplify a bunch of IfCondition

Post by eclectic-tech »

When you use Section Variables in a measure or meter, you need to add DynamicVariables=1 to those sections.

You use InlinePattern=[MeasureTodayName] and InlinePattern=[MeasureTodayNunmber] in [MeterDayName] and [MeterDayNumber], so adding DynamicVariables=1 to those 2 sections will make the meters update correctly when the measure values change.