It is currently March 29th, 2024, 3:24 pm

Section variables in formulae

Get help with creating, editing & fixing problems with skins
basileus
Posts: 4
Joined: April 26th, 2017, 6:51 am

Section variables in formulae

Post by basileus »

I'm trying to make a RAM/swap bar meter which changes color depending upon the amount of RAM used. To that end, my code for coloring the bar works, but the code doing some calculations does not. The Rainmeter log reports syntax errors in both of these sections. It also says that there is a Formula: Syntax error in key "MaxValue" in [SwapCalc] (Wisp\Ram\Ram.ini). How do I do assign the MaxValue for my [SwapCalc] measure if this is not allowed? I don't want to assign it a static value.

Code: Select all

[SwapCalc]
Measure=Calc
Formula=([SwapMemory:] - [PhysicalMemory:])
MinValue=0
MaxValue=([SwapMemory:MaxValue] - [PhysicalMemory:MaxValue])
Substitute="k":"KB","M":"MB","G":"GB"
IfAboveValue=0
IfAboveAction=[!SetOption "SwapText" "Text" "%1"]
IfBelowValue=0
IfBelowAction=[!SetOption "SwapText" "Text" "0.0 KB"]

[CalcRamUsage]
Measure=Calc
Formula=([PhysicalMemory:%])
I'm doing this according to the docs for section variables - where have I gone wrong?

Thanks in advance!
Last edited by basileus on April 26th, 2017, 7:12 am, edited 3 times in total.
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Section variables in formulae

Post by Brian »

Looks like you just need DynamicVariables=1.

https://docs.rainmeter.net/manual-beta/variables/#DynamicVariables

Code: Select all

[SwapCalc]
Measure=Calc
Formula=([SwapMemory:] - [PhysicalMemory:])
MinValue=0
MaxValue=([SwapMemory:MaxValue] - [PhysicalMemory:MaxValue])
Substitute="k":"KB","M":"MB","G":"GB"
IfAboveValue=0
IfAboveAction=[!SetOption "SwapText" "Text" "%1"]
IfBelowValue=0
IfBelowAction=[!SetOption "SwapText" "Text" "0.0 KB"]
DynamicVariables=1

[CalcRamUsage]
Measure=Calc
Formula=([PhysicalMemory:%])
DynamicVariables=1
-Brian
basileus
Posts: 4
Joined: April 26th, 2017, 6:51 am

Re: Section variables in formulae

Post by basileus »

Nope - Same errors with or without DynamicVariables=1. Also, with DynamicVariables=1, the Formula: Syntax error in key "MaxValue" in [SwapCalc] (Wisp\Ram\Ram.ini) error keeps repeating in the log.
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Section variables in formulae

Post by Brian »

It's hard to say what the problem is without seeing the other measures involved (specifically the SwapMemory and PhysicalMemory measures).

I suspect there is either a typo in the .ini skin file, or the calculation is negative.

-Brian
basileus
Posts: 4
Joined: April 26th, 2017, 6:51 am

Re: Section variables in formulae

Post by basileus »

Brian wrote:It's hard to say what the problem is without seeing the other measures involved (specifically the SwapMemory and PhysicalMemory measures).

I suspect there is either a typo in the .ini skin file, or the calculation is negative.

-Brian
The SwapMemory and PhysicalMemory measures are the inbuilt ones.
basileus
Posts: 4
Joined: April 26th, 2017, 6:51 am

Re: Section variables in formulae

Post by basileus »

Turns out I didn't know that SwapMemory and PhysicalMemory aren't actually measures by themselves, just providers. Sorry for the trouble.
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Section variables in formulae

Post by Brian »

No trouble at all. :thumbup: Hopefully you have it all working now.

-Brian