It is currently October 3rd, 2023, 6:36 pm

Can you help me with a formula?

Get help with creating, editing & fixing problems with skins
User avatar
tass_co
Posts: 498
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Can you help me with a formula?

Post by tass_co »

Hi,

I have a skin that informs me about the dates of new TV series.
When I press the X2 key, it increases the episode by 1 and the day by 7.
My problem here is that if the day and section values are less than 10, I want it to add a "0" in front of them.

It needs to control 26 variables. I don't want to write separate formulas for each variable.
Could there be an easier way to do this?
A ready-made Lua script can also work for me :D
18.09.2023 - 18.41.18-Window.png
Part of the code

Code: Select all

[Item1Highlight]
Meter=Image
MeterStyle=HighlightStyle
Group=PAGE1
X=5
Y=8
LeftMouseUpAction=#Down1#
MiddleMouseUpAction=#IMDB1#
RightMouseUpAction=#Sub1#
X1MouseUpAction=["#Note#"]
X2MouseUpAction=[!WritekeyValue Variables Day1 "((#Day1#)+7)" "#@#TVShows.inc"][!WritekeyValue Variables Epi1 "((#Epi1#)+1)" "#@#TVShows.inc"][!Refresh]
MouseScrollDownAction=[!ToggleMeterGroup PAGE1][!ToggleMeterGroup PAGE2][!Redraw]
Hidden=0
DynamicVariables=1

[Item1]
Meter=String
MeterStyle=StyleRSS
Group=PAGE1
FontColor=255,255,255,255
X=10
Y=8
Text=#Name1#
MouseScrollDownAction=[!ToggleMeterGroup PAGE1][!ToggleMeterGroup PAGE2][!Redraw]
Hidden=0
DynamicVariables=1

[Item1Date]
Meter=String
MeterStyle=StyleRSS
Group=PAGE1
FontColor=255,255,255,255
Y=8
X=159
Text=#SE1#>#ChkTime1#
MouseScrollDownAction=[!ToggleMeterGroup PAGE1][!ToggleMeterGroup PAGE2][!Redraw]
Hidden=0
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 6073
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can you help me with a formula?

Post by Yincognito »

Use a regex substitution to add sufficient zeros before the number and then remove the surplus of zeros before the desired amount of digits you need to have for the final string, for example something like:

RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"

This is not tested, but you get the idea. You can further adjust patterns to suit your needs. Obviously, you'll then need to use the measure values where you do this, instead of the original variables (or even set the variables to the measure values, if you prefer it like that).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
tass_co
Posts: 498
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Can you help me with a formula?

Post by tass_co »

Yincognito wrote: September 18th, 2023, 9:00 pm Use a regex substitution to add sufficient zeros before the number and then remove the surplus of zeros before the desired amount of digits you need to have for the final string, for example something like:

RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"

This is not tested, but you get the idea. You can further adjust patterns to suit your needs. Obviously, you'll then need to use the measure values where you do this, instead of the original variables (or even set the variables to the measure values, if you prefer it like that).
Thank you :bow:
The Regexp code works fine for section numbers, but it does not work for dates...
The dates appear as "022.09.23"
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 6073
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can you help me with a formula?

Post by Yincognito »

tass_co wrote: September 18th, 2023, 9:53 pm Thank you :bow:
The Regexp code works fine for section numbers, but it does not work for dates...
The dates appear as "022.09.23"
It works for me...

Code: Select all

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

---Measures---

[ZeroPadded]
Measure=String
String="22.9.23"
RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"

---Meters---

[SomeMeter]
Meter=String
FontColor=255,255,255,255
SolidColor=0,0,0,255
FontSize=16
AntiAlias=1
MeasureName=ZeroPadded
Text=%1
Zero Padded.jpg
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
tass_co
Posts: 498
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Can you help me with a formula?

Post by tass_co »

Yincognito wrote: September 18th, 2023, 10:30 pm It works for me...
But the content is not exactly like that :oops:

As follows:

Text=#SE2#>#ChkTime2#

#SE2#=S02E07
(>)
#ChkTime2#=022.09.23

Code: Select all

[Item2Date]
Meter=String
MeterStyle=StyleRSS
Group=PAGE1
FontColor=255,255,255,255
X=159
Text=#SE2#>#ChkTime2#
MouseScrollDownAction=[!ToggleMeterGroup PAGE1][!ToggleMeterGroup PAGE2][!Redraw]
Hidden=0
DynamicVariables=1
RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
Yincognito
Rainmeter Sage
Posts: 6073
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can you help me with a formula?

Post by Yincognito »

tass_co wrote: September 18th, 2023, 10:58 pm But the content is not exactly like that :oops:

As follows:

Text=#SE2#>#ChkTime2#

#SE2#=S02E07
(>)
#ChkTime2#=022.09.23

Code: Select all

[Item2Date]
Meter=String
MeterStyle=StyleRSS
Group=PAGE1
FontColor=255,255,255,255
X=159
Text=#SE2#>#ChkTime2#
MouseScrollDownAction=[!ToggleMeterGroup PAGE1][!ToggleMeterGroup PAGE2][!Redraw]
Hidden=0
DynamicVariables=1
RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"
Well, the content and the way you code it is up to you, not me... what you posted can't work if after all this time, you still add options that are specific to measures (like those related to the substitution) to meters instead... :confused:

Again, it works for me... :D

Code: Select all

[Variables]
SE2=S02E07
ChkTime2=022.09.23

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

---Measures---

[ZeroPadded]
Measure=String
String=#SE2#>#ChkTime2#
RegExpSubstitute=1
Substitute="(\d+)":"0\1","\d*(\d{2})":"\1"

---Meters---

[SomeMeter]
Meter=String
FontColor=255,255,255,255
SolidColor=0,0,0,255
FontSize=16
AntiAlias=1
MeasureName=ZeroPadded
Text=%1
Zero Padding.jpg
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth