It is currently April 19th, 2024, 11:36 am

Trick for repeating @Include sections?

Get help with creating, editing & fixing problems with skins
User avatar
didjit
Posts: 3
Joined: November 29th, 2015, 4:37 am

Trick for repeating @Include sections?

Post by didjit »

I haven't seen an answer for this, or even discussion about there being no answer...

I'm trying to find an elegant way to reuse "code". For example, to create a series of buttons I'd like to have a ButtonTemplate.inc file that gets included multiple times like so:

Code: Select all

[Button1]
@Include1=#CURRENTPATH#ButtonTemplate.inc

[Button2]
@Include2=#CURRENTPATH#ButtonTemplate.inc

[Button3]
@Include3=#CURRENTPATH#ButtonTemplate.inc
But I can't figure out how to increment section and variable names. I think I'd want to do something like this:

Code: Select all

[Meter#Index#]
Meter=Button
X=0
Y=(#Spacing# * #Index#)
ButtonImage=#@#Images\Button#Index#.png
ButtonCommand=[*Action#Index#*]
DynamicVariables=1
But then even if that worked, how could you increment #Index# with each instantiation? I had a couple thoughts. Maybe something like this where the included section could update the index itself:

Code: Select all

[Count[#Index#]]
Measure=String
String=""
OnUpdate=[!SetVariable Index ([#Index#] + 1)]
DynamicVariables=1
Or perhaps something like this where the index could be read from the including section:

Code: Select all

; in Skin.ini
[Button1]
@Include=Template.inc

Code: Select all

;in Template.inc
Measure=Calc
Formula=#CURRENTSECTION#
Substitute="Button":""
OnUpdate=[!SetVariable Index [#CURRENTSECTION#]]
DynamicVariables=1
So at this point, the possibilities were no longer looking elegant. But I figure someone else has either worked it out or determined it can't be done. Any answers anyone?
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: Trick for repeating @Include sections?

Post by Ragingwasabi »

idk about the section names, but for x and y position why dont u just use relative positioning?

y = 50r
50 pixels from the end of the previous meter
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trick for repeating @Include sections?

Post by balala »

Ragingwasabi wrote:idk about the section names, but for x and y position why dont u just use relative positioning?

y = 50r
50 pixels from the end of the previous meter
Just one small error: y = 50r means 50 pixels from the begining of the previous meter (according to the manual: "If the value is appended with r, the position is relative to the top/left edge of the previous meter"). "50 pixels from the end of the previous meter" would be translated in "Rainmeter language" as y = 50R (also from the manual: "If the value is appended with R, the position is relative to the bottom/right edge of the previous meter.").
User avatar
didjit
Posts: 3
Joined: November 29th, 2015, 4:37 am

Re: Trick for repeating @Include sections?

Post by didjit »

Oh, that's great! I'm new at this and didn't know about that trick. It's a start. Thanks!