It is currently March 28th, 2024, 10:13 am

Global or public variables

Get help with creating, editing & fixing problems with skins
Post Reply
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Global or public variables

Post by csm725 »

Is there such thing as a 'global' or 'public' variable in Rainmeter?
in rainmeter you can have a global variable but when you, say, add 5 to it and display it on another skin, it will not show the value before + 5, it will show just the value before.
ie a @include to a variables file where

Code: Select all

a=5
Then I have two configs open, each one with update=200. I do !RainmeterSetVariable a (#a#+5) and of course it only modifies 'a' in the skin where I set the variable.
I am thinking there's a way to do it with !RainmeterWriteKeyValue. Is it possible?
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Global or public variables

Post by Aarowaim »

Let me make the following quote from the user guide (conveniently on the main area of this website):
http://rainmeter.net/cms/Bangs_beta wrote:!RainmeterWriteKeyValue [Section] [Key] [Value] ("FileSpec")
Allows for permanently writing / changing any Key=Value in any Rainmeter .ini or other ini formatted file such as a .inc @Include file. "Section" is the section name such as [Rainmeter], "Key" and "Value" are the Key=Value pairs such as FontSize=15. "FileSpec" is optional. If included, it will make the change to the specified file as long as the file exists and is in the \Skins or %APPDATA%\Rainmeter paths. Thus, you can write to any skin .ini / .inc or Rainmeter.ini. For a change to a file to take effect, a refresh of the skin (or Rainmeter) is required.


In your case, let's say your included file with all the variables is saved in Skins\myskin and it's name is globalvariables.inc, you would use the following bang:

Code: Select all

!RainmeterWriteKeyValue Variables a (#a#+5) #SKINSPATH#\myskin\globalvariables.inc
This bang says to change the value of "a" in the variables section of globalvariables.inc into (#a#+5)

Please, before you post, please try to find the information by yourself. But if you don't understand what is posted in the manual, don't be afraid to ask :D .
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Global or public variables

Post by csm725 »

So you see, my code for !RainmeterWriteKeyValue was this:

Code: Select all

IfEqualAction=!execute [!RainmeterWriteKeyValue variables postfix #postfix# "#ROOTCONFIGPATH#\Vars\Vars.inc"]
I did try, I'm not just being ignorant...
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Global or public variables

Post by Aarowaim »

I never tried to imply that you were ignorant, but I'm sorry if I did. Anyway, let me point out something:
http://rainmeter.net/cms/Bangs_beta wrote:"FileSpec" is optional. If included, it will make the change to the specified file as long as the file exists and is in the \Skins or %APPDATA%\Rainmeter paths.
The bang you tried using is refering to the root config path. the simple fix is to move the file to the skins or appdata\rainmeter path. Don't worry, sometimes even I miss an important thing... Fine... I miss important things quite often, but I'm happy when they are pointed out :D .
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Global or public variables

Post by jsmorley »

#ROOTCONFIGPATH# is in the \Skins folder tree, and is not a problem. From the manual:

#ROOTCONFIGPATH#
- The path to the highest level folder under \Skins for the current config.

The problem that I see is that #ROOTCONFIGPATH# already ends in "\" so you don't need to add it.

"#ROOTCONFIGPATH#\Vars\Vars.inc"

"#ROOTCONFIGPATH#Vars\Vars.inc"
csm725
Posts: 46
Joined: August 16th, 2010, 4:29 pm

Re: Global or public variables

Post by csm725 »

I'll try to take out the unnecessary forward-slash when I'm back on my laptop. Thanks for pointing that out though.
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Global or public variables

Post by Aarowaim »

Thank you very much for the correction jsmorley. :)
As I said:
Aarowaim wrote:Don't worry, sometimes even I miss an important thing... Fine... I miss important things quite often, but I'm happy when they are pointed out :D .
Sorry about my ignorance, I guess I'm the somewhat rainmeterically correct newbie. ;)
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Global or public variables

Post by jsmorley »

What I found works for me is to limit myself to helping one to two folks a day on average. That way I can take the time to double check the manual, and in most cases even write a little test skin to ensure that what I am about to suggest really works the way I think it does.

If everyone who was fairly familiar with Rainmeter helped just one or two guys a day, nobody would have to work like a dog firing off quick solutions and all questions would be answered. There are enough Rainmeter geeks around that nobody has to do it all.

Not pointing fingers at you at all, but in general, a wrong answer is worse by far than no answer. Particularly as that wrong answer is going to show up when folks search the forums until the end of time. Not that any of us are perfect, know it all, and never make a mistake. However, do keep in mind that in a sense we are building a community "knowledge base" here in the forums. Every time you help someone (and we certainly enthusiastically encourage that!) you not only help that poster, but many who come after.

The key is to really look at what the poster is asking, and what information is provided. About 70% of the time, the poster does not provide enough details to even make an educated guess at the solution. Don't be afraid to ask them to post their code, a link to the skin they are struggling with, or a better description of the problem. Make them help you to help them.
Post Reply