It is currently September 29th, 2024, 3:34 pm

Calc external variables

General topics related to Rainmeter.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Calc external variables

Post by rbriddickk84 »

Hi!

I've got some strange difficoulties with matching two external variables in a calc measure.

I have an external inc file with two variables in it:

Code: Select all

[Variables]
a=1
b=1
And i have the ini file with measuring those two var:

Code: Select all

[Variables]
@Include=..\@Resources\tmp.inc
run=0
ypos=0

[Substituter]
Measure=Calc
ifCondition=(#a# = 1)
ifTrueAction=[!SetVariable ypos 22]
ifCondition2=(#a# = 2)
ifTrueAction2=[!SetVariable ypos 47]
DynamicVariables=1

[Check]
Measure=Calc
ifCondition=(#a# > #b#)
ifTrueAction=[!SetVariable run 5]
DynamicVariables=1

[CountUp]
Measure=Calc
Formula=(CountUp + #run#)
ifAboveValue=25
ifAboveAction=[!SetVariable run 0]
DynamicVariables=1
All i want is to change "ypos" and "run" variables on .ini refresh.

My issue is this: In the [Substituter] section works fine, the "ypos" variable changing on refresh perfectly.
But the "run" variable didn't change. Not with Redraw, or Refresh.
I read over and over the code, but cannot have a clue what i did wrong!
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Calc external variables

Post by moshi »

the run variable does change. initially it changes from 0 to 5 and then it changes back to 0 after six updates. (if a>b) just as you configured it here:

Code: Select all

ifAboveValue=25
ifAboveAction=[!SetVariable run 0]
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Calc external variables

Post by rbriddickk84 »

moshi wrote:the run variable does change. initially it changes from 0 to 5 and then it changes back to 0 after six updates. just as you configured it here:

Code: Select all

ifAboveValue=25
ifAboveAction=[!SetVariable run 0]
Wow, that is getting stranger! At me it doesn't changes, no matter how i changed the code, and tried!
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calc external variables

Post by jsmorley »

rbriddickk84 wrote:Hi!

I've got some strange difficoulties with matching two external variables in a calc measure.

I have an external inc file with two variables in it:

Code: Select all

[Variables]
a=1
b=1
And i have the ini file with measuring those two var:

Code: Select all

[Variables]
@Include=..\@Resources\tmp.inc
run=0
ypos=0

[Substituter]
Measure=Calc
ifCondition=(#a# = 1)
ifTrueAction=[!SetVariable ypos 22]
ifCondition2=(#a# = 2)
ifTrueAction2=[!SetVariable ypos 47]
DynamicVariables=1

[Check]
Measure=Calc
ifCondition=(#a# > #b#)
ifTrueAction=[!SetVariable run 5]
DynamicVariables=1

[CountUp]
Measure=Calc
Formula=(CountUp + #run#)
ifAboveValue=25
ifAboveAction=[!SetVariable run 0]
DynamicVariables=1
All i want is to change "ypos" and "run" variables on .ini refresh.

My issue is this: In the [Substituter] section works fine, the "ypos" variable changing on refresh perfectly.
But the "run" variable didn't change. Not with Redraw, or Refresh.
I read over and over the code, but cannot have a clue what i did wrong!
If you change a=1 to a=2 in the include file, then when you refresh the skin the value of the variable "run" changes to 5, as expected, since now #a# > #b# and !SetVariable sets the value of "run" to 5. The value of [CountUp] counts by 5 to 30, then the value of "run" is set back to 0. That causes [CountUp] to stop.

That is the expected behavior of this code. "run" will always end up as 0 one way or the other, and will certainly always start out as 0 when you refresh.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Calc external variables

Post by moshi »

you might be using a wrong path here:

Code: Select all

@Include=..\@Resources\tmp.inc
if you are not already doing it, i strongly suggest using the "Skins" tab in Rainmeter's "About" Window to keep track of measures and variables.
http://docs.rainmeter.net/manual/user-interface/about#SkinsTab
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calc external variables

Post by jsmorley »

I'm not sure, but I have a feeling you might be trying to create a "loop", and are coming at it in some kind of "brute force" hard way.

You might want to take a look at http://rainmeter.net/forum/viewtopic.php?f=15&t=17588
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Calc external variables

Post by rbriddickk84 »

The path is good, i use a lots of variables from there!

I tried this code too:

Code: Select all


[CountUp]
Measure=Calc
Formula=(CountUp + #run#)
ifEqualValue=25
ifEqualAction=[!SetVariable run 0][!WriteKeyValue Variables "b" "#a#" "#SKINSPATH#Program\@Resources\tmp.inc"]
DynamicVariables=1

My ini file and my tmp.inc file opened in text editor to see if something changes, but the counter for me was never counted and never started to counting. I writed out in a String that counter's value, and set to Dynamic, to see if counting, but remain 0, and in the .inc file everything is remain the same too, no matter how i change #a#!

I don't want to create a loop, just if #a# different from #b# in the .inc file, then on refresh the counter start to count, and stop at a value.
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calc external variables

Post by jsmorley »

Not sure, but I promise that if you run your code exactly as you had it in your first post, open up the About / Skins panel so you can watch variables and measure values change in real time, then change a=1 to a=2 in the include file, save that, and refresh the skin, you will see the variable "run" change to 5, that measure value count by 5 from 0 to 30, and then "run" change back to 0. The value of the measure will remain 30.

It happens fairly quickly, so you have to have About / Skins open and visible when you refresh.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Calc external variables

Post by rbriddickk84 »

jsmorley wrote:Not sure, but I promise that if you run your code exactly as you had it in your first post, open up the About / Skins panel so you can watch variables and measure values change in real time, then change a=1 to a=2 in the include file, save that, and refresh the skin, you will see the variable "run" change to 5, that measure value count by 5 from 0 to 30, and then "run" change back to 0. The value of the measure will remain 30.

It happens fairly quickly, so you have to have About / Skins open and visible when you refresh.
I renamed here the values for to represent more easy my code's structure.
I opened up the About window, and my run variables are remain 0.
So i have to restructurize/rename all the variables, to might be working that way? That would be build up all the code from zero, becouse all other elements are depends on those variables, what you can find in the .inc file. I checked over and over, character by character for writing errors, mistakes, but basically my code is exactely the same what i copied here, only the variable names here are minimal, e.g.: #a# (in my .inc file is #btnum#)
(this work is still the buttoncount stuff)
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calc external variables

Post by jsmorley »

Don't know. The name of variables is not particularly relevant, as long as you stay away from spaces or special characters in them, and don't create some kind of logic conflict by using the same #VarName# different places to do conflicting things.