It is currently April 26th, 2024, 4:00 pm

How to put a variable in a variable!!

Get help with creating, editing & fixing problems with skins
DeathByChocolate
Posts: 26
Joined: September 17th, 2014, 8:47 pm

How to put a variable in a variable!!

Post by DeathByChocolate »

im making a skin that has some launchers but i want to use a style to (make my skin shorter.

Code: Select all

[variables]
launch1name=chrome

[launchstyle]
text=##currentsection#name#

[launch1]
meter=string
meterstyle=launchstyle
is there a way of seperating the currentsection variable and the launch1name variable
Last edited by DeathByChocolate on April 21st, 2015, 6:36 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put a variable in a variable!!

Post by balala »

A while ago I had almost the same question. Then moshi had a great idea. Try to figure out how you could use it, or if you can't, give a feedback and I'll try to help you.
DeathByChocolate
Posts: 26
Joined: September 17th, 2014, 8:47 pm

Re: How to put a variable in a variable!!

Post by DeathByChocolate »

I have elaborated on my skin a bit more, and I have added the Measure, but to no avail...

Code: Select all

[Variables]
Launcher1Name=Chrome
Launcher2Name=Photoshop

[MeasureText]
Measure=String
String=#CurrentSection#
RegExpSubstitute=1
Substitute="^Launcher1$":"#Launcher1Name#","^Launcher2$":"#Launcher2Name#"

[LauncherStyle]
X=10R
Y=20
W=40
H=40
Text=[MeasureText]
SolidColor=230,230,230

[Launcher1]
Meter=String
MeterStyle=LauncherStyle
LeftMouseUpAction=["#Launcher1Path#"]
I've never used a string measure, so I am not that sure what exxactly is meant to be happening, but all I know is that it doesn't work and the only thing that the meter dispalys is 'MeasureTime'
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put a variable in a variable!!

Post by balala »

I'm not quite sure what you'd like to do. Please explain a bit.
DeathByChocolate
Posts: 26
Joined: September 17th, 2014, 8:47 pm

Re: How to put a variable in a variable!!

Post by DeathByChocolate »

Well, pretty much I have multiple launcher skins which are all very identical, other then the variables (i.e Name, Path etc.)

Code: Select all

[Variables]
Launcher1Name=Chrome
Launcher2Name=Photoshop
Launcher3Name=Word
Launcher4Name=Explorer

[LauncherStyle]
Text=##CurrentSection#Name#

[Launcher1]
Meter=String
MeterStyle=LauncherStyle

[Launcher2]
Meter=String
MeterStyle=LauncherStyle

[Launcher3]
Meter=String
MeterStyle=LauncherStyle

[Launcher4]
Meter=String
MeterStyle=LauncherStyle
What is meant to happen here is that each launcher gets the Text from the style, and it is meant to instantly replace the #CurrentSection# with the section name, so for example the first launcher meter should replace the #CurrentSection# with 'Launcher1', which becomes #Launcher1Name# due to the Text in LauncherStyle.

Did I explain it well enough?
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put a variable in a variable!!

Post by balala »

Yes, you did, but working with it, I don't think it's a viable option. Instead you have to add the Text option to every string meter one by one. Sorry...
DeathByChocolate
Posts: 26
Joined: September 17th, 2014, 8:47 pm

Re: How to put a variable in a variable!!

Post by DeathByChocolate »

No problem, and thanks. It's just I have a ton of variables like Name, Size, Path, Icon etc. so I was hoping I would be able to shorten it, but it's not the end of the universe ;)
User avatar
Yincognito
Rainmeter Sage
Posts: 7171
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to put a variable in a variable!!

Post by Yincognito »

There isn't a way to put a variable in a variable, but it is possible to put a variable inside a measure. So, if you "transform" the variables that you want to include other variables into to measures, I think it might work. It certainly does for me, for a similar example.

What you'll have to do is write a [LauncherXName] measure for each #LauncherXName# variable (where X is the number ranging from 1 to 4) and "measure" the strings ("Chrome", "Photoshop", etc.) with them. So instead of trying to make a #a#b## work, you should try something like [a#b#], which should work.

Therefore, your code would look something like :

Code: Select all

[Launcher1Name]
Measure=String
String=Chrome

[Launcher2Name]
Measure=String
String=Photoshop

[Launcher3Name]
Measure=String
String=Word

[Launcher4Name]
Measure=String
String=Explorer

[LauncherStyle]
Text=[#CurrentSection#Name]

[Launcher1]
Meter=String
MeterStyle=LauncherStyle

[Launcher2]
Meter=String
MeterStyle=LauncherStyle

[Launcher3]
Meter=String
MeterStyle=LauncherStyle

[Launcher4]
Meter=String
MeterStyle=LauncherStyle
Try it and let me know if it works. It definitely should.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to put a variable in a variable!!

Post by jsmorley »

Yes. The key to all this is how variables and measures are "resolved".

Variables are resolved before measures.
So [Measure#Var#] works
but #Var[Measure]# doesn't

Variables are parsed and resolved in the order they are used.
So while #Var1##Var2# works
#Var1#Var2## doesn't