It is currently April 27th, 2024, 4:01 pm

[Suggestion] Read variable within an ini/inc without Including it

Report bugs with the Rainmeter application and suggest features.
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

[Suggestion] Read variable within an ini/inc without Including it

Post by Cariboudjan »

Eg.

[!ReadVariable MyVariable MyVariable1 “My\Variable1\Location.ini”]

[!ReadVariable MyVariable MyVariable2 “My\Variable2\Location.ini”]

[!ReadVariable MyVariable MyVariable3 “My\Variable3\Location.ini”]

Creates variables:

MyVariable1=Value1
MyVariable2=Value2
MyVariable3=Value3

I have multiple inc files that contain a variable of the same name by design, and therefor an Include= would not work. But if I can read that variable value, and assign it a different name, I can set multiple values from a variable of the same name from multiple files.
User avatar
balala
Rainmeter Sage
Posts: 16177
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Suggestion] Read variable within an ini/inc without Including it

Post by balala »

I'm not a developer, however I strongly doubt this will ever be implemented. But it's not even needed in my opinion, unless I misunderstood something. You could add a MyVariable1=#MyVariable# option to the [Variables] section of the My\Variable1\Location.ini file, a MyVariable2=#MyVariable# to the My\Variable2\Location.ini file and so on.
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: [Suggestion] Read variable within an ini/inc without Including it

Post by Cariboudjan »

No. That won’t work. Because each file does not know if it is Variable1, Variable2, Variable3, etc.

And since Variable Names cannot themselves contain variables that’s not possible.

Eg. Variable#IndexNum#=Value

You’re talking about adding fixed values but the point is for making something dynamic. Eg. Modules that are customizable for a skin, that each contain variables of the same name, but need to be read by a central skin independently in order to control them.

What MIGHT be possible, but haven’t tested is:



@include1=My\Variable1\Location.ini

NewVariable1=#MyVariable#

@include2=My\Variable2\Location.ini

NewVariable2=#MyVariable#



But I’m 99% positive the variables do not parse linearly this way.
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Suggestion] Read variable within an ini/inc without Including it

Post by Yincognito »

Cariboudjan wrote: March 28th, 2024, 5:38 pmYou’re talking about adding fixed values but the point is for making something dynamic. Eg. Modules that are customizable for a skin, that each contain variables of the same name, but need to be read by a central skin independently in order to control them.
Well, you could use WebParsers for the MyVariable values in those Location.ini files, and replicate what @include does (a bit redundant and with some delay, I know)... :???: Another possibility would be to read the files with Lua and do your thing, but in that case you'd have to pay a little attention to the file encodings.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Cariboudjan
Posts: 268
Joined: May 12th, 2019, 8:55 am

Re: [Suggestion] Read variable within an ini/inc without Including it

Post by Cariboudjan »

Could use WebParser - But... Eh... Maybe... I'll think about it.