It is currently April 23rd, 2024, 11:17 am

Import variable from another file?

Get help with creating, editing & fixing problems with skins
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Import variable from another file?

Post by deXxterlab97 »

I have no clue but seems it is possible
Say I write down a variable to a file so that other skins I have can reuse that variable

I have 10 separate skins so if let's say someone input color, font size and stuff like that into one single file and it gets transferred to all other remaining skins

I just need to find out how, I can figure the rest on my one (like a small tip)

Also would be nice if I someone can point me a way to make it interactive (like instead of editing ini file user can load that ini skin and have a bar where they can enter those data I mentioned above cause I've seen them doing but looks too complicated to read for me)
deXxterlab97
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Import variable from another file?

Post by CyberTheWorm »

The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Import variable from another file?

Post by balala »

deXxterlab97 wrote:Say I write down a variable to a file so that other skins I have can reuse that variable

I have 10 separate skins so if let's say someone input color, font size and stuff like that into one single file and it gets transferred to all other remaining skins
Problem is that even if you're including the file where you write those variables, into each of the 10 skins, you'll have to refresh the skins in order to the newly written variables can be used.

I'd suggest another approach: write those variables in to the appropriate file and in parallel, use some !SetVariableGroup (or !SetVariable) bangs to set the values of the variables in each skin.
The simplest approach to do this, I think would be the following one: first add each of the desired skins, to a group. So, add a Group=MyGroup option to the [Rainmeter] section of each skin.
Then where you want to write the variable into the shared file (where the, probably, !WriteKeyValue bang is used), add a this kind of bang: [!SetVariableGroup FontSize "12" "MyGroup"], to set the value of the FontSize variable, in each skin belonging to the MyGroup group. This bang will set the FontSize variable in those skins to 12.
Obviously this was just an example of how can you achieve what you want. For further help, it would be nice to post some code.
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Import variable from another file?

Post by deXxterlab97 »

balala wrote:Problem is that even if you're including the file where you write those variables, into each of the 10 skins, you'll have to refresh the skins in order to the newly written variables can be used.

I'd suggest another approach: write those variables in to the appropriate file and in parallel, use some !SetVariableGroup (or !SetVariable) bangs to set the values of the variables in each skin.
The simplest approach to do this, I think would be the following one: first add each of the desired skins, to a group. So, add a Group=MyGroup option to the [Rainmeter] section of each skin.
Then where you want to write the variable into the shared file (where the, probably, !WriteKeyValue bang is used), add a this kind of bang: [!SetVariableGroup FontSize "12" "MyGroup"], to set the value of the FontSize variable, in each skin belonging to the MyGroup group. This bang will set the FontSize variable in those skins to 12.
Obviously this was just an example of how can you achieve what you want. For further help, it would be nice to post some code.
I guess this kinda solves my problem. Thanks

I just have this small Variables

Code: Select all

[Variables]
FontFace=Ubuntu
FontColor=255,255,255,240
FontSize=11
deXxterlab97
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Import variable from another file?

Post by deXxterlab97 »

CyberTheWorm wrote:Have you had a look at this?
https://docs.rainmeter.net/tips/include-guide/
Yeah that's what I was looking for. How does that different from what balala did?
deXxterlab97
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Import variable from another file?

Post by balala »

deXxterlab97 wrote:I guess this kinda solves my problem.
Does it?
deXxterlab97 wrote:Yeah that's what I was looking for. How does that different from what balala did?
With an @Include option, you can add an ini formatted file to your code and your skin will be able to use the variables (sections) of the included file. But as I said, if simply write a variable in that file, the skin won't be able to use the newly written variable, just if you refresh the skin. That's why I proposed to set the value of the variable (with the !SetVariable or the !SetVariableGroup bang) into all skins, when it is written to the included file.
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

Re: Import variable from another file?

Post by deXxterlab97 »

balala wrote:Does it?

With an @Include option, you can add an ini formatted file to your code and your skin will be able to use the variables (sections) of the included file. But as I said, if simply write a variable in that file, the skin won't be able to use the newly written variable, just if you refresh the skin. That's why I proposed to set the value of the variable (with the !SetVariable or the !SetVariableGroup bang) into all skins, when it is written to the included file.
ok thanks
deXxterlab97
User avatar
balala
Rainmeter Sage
Posts: 16162
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Import variable from another file?

Post by balala »

You're welcome.
If you have any other question, just please let me (us) know.