It is currently March 29th, 2024, 12:03 pm

Array Variables

Report bugs with the Rainmeter application and suggest features.
LordgodEric
Posts: 10
Joined: April 21st, 2013, 1:46 pm

Array Variables

Post by LordgodEric »

Would it be possible to implement "Array" variables within Rainmeter?

Thanks for any help or suggestions.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Array Variables

Post by balala »

LordgodEric wrote: February 9th, 2019, 10:47 am Would it be possible to implement "Array" variables within Rainmeter?
I'd say it's not, but what are you exactly thinking about?
LordgodEric
Posts: 10
Joined: April 21st, 2013, 1:46 pm

Re: Array Variables

Post by LordgodEric »

Mainly being able to process an unknown number of the same calculations on some data sets without having to individually name each variable or measure. So I could use just one "function" measure (calculation) to perform the function. I imagine this could be done via Lua plugin, but the tutorials I have found are kind of vague as to how exactly it links into Rainmeter and how to pass data back and forth.
rxtd
Posts: 100
Joined: April 30th, 2017, 11:51 am

Re: Array Variables

Post by rxtd »

LordgodEric wrote: February 15th, 2019, 11:48 aman unknown number of the same calculations on some data sets
I believe you need loops for such a thing. Rainmeter isn't built to have loops, they are quite tricky to write.
I really doubt it will be easier to use than scripts in Lua.
LordgodEric wrote: February 15th, 2019, 11:48 amhaving to individually name each variable or measure
I'm not a Rainmeter dev but I say that measures aren't ever gonna be defined as arrays.
If you only need to access them using some index then you can use nested variables. Write

Code: Select all

[variables]
qwe_1=a
qwe_2=b
x=1
And then you can use it like this: [#qwe_[#x]]. Also works with measures: [&MeasureName[#x]].
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Array Variables

Post by balala »

LordgodEric wrote: February 15th, 2019, 11:48 am Mainly being able to process an unknown number of the same calculations on some data sets without having to individually name each variable or measure. So I could use just one "function" measure (calculation) to perform the function. I imagine this could be done via Lua plugin, but the tutorials I have found are kind of vague as to how exactly it links into Rainmeter and how to pass data back and forth.
Or, beside rxtd's reply, as you thought, a Lua script can be used (it's not a plugin though). If properly written (to use Inline Lua) it is an extremely versatile tool.
For example, in the attached skin, the value of the [MeasureCalc] measure is increased by 1 at each update of the skin. This value is get by the Double function of the lua script file and doubled by this function. The result is returned to the String meter of the skin. Obviously a such operation can be made much more easier by a simple Calc measure, the meaning of this lua script is just to demonstrate how this Inline Lua feature is working.
Also note that if inline lua is used, the [MeasureLuaScript] Script measure can be even disabled (and in this case it is), the function used through it still works.
You do not have the required permissions to view the files attached to this post.
LordgodEric
Posts: 10
Joined: April 21st, 2013, 1:46 pm

Re: Array Variables

Post by LordgodEric »

Thanks for all the info folks.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Array Variables

Post by balala »

LordgodEric wrote: February 18th, 2019, 10:22 am Thanks for all the info folks.
Did the Inline Lua help?
LordgodEric
Posts: 10
Joined: April 21st, 2013, 1:46 pm

Re: Array Variables

Post by LordgodEric »

Sorry, it took me so long to get back to you. But yes the inline lua did work. It was a little tricky but it did work thanks.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Array Variables

Post by balala »

LordgodEric wrote: November 6th, 2019, 11:37 am But yes the inline lua did work. It was a little tricky but it did work thanks.
Ok, I'm glad.