Help with If and !SetVariable

Help with creating, editing & fixing problems with skins

Help with If and !SetVariable

November 18th, 2017, 12:57 am
LazyLaubert
   [2 posts]

Hello, guys,
I hope you can help me.

I have written a meter that can be extendet in two ways. (by click)
But when you open both things at the same time, they overlap.
So I wanted to write an if statement that if both meters are open, a
variable changes so that they are again next to each other.

I would like to show and explain my code:
cpuHidden is a variable that =1 if the meter"CPU" is closed.
Analogously ramHidden with the meter "RAM".
cpuHiddenPositionX is the x-variable of the CPU meter(by default "#monitorWidth#-420" (just like the RAM window)
But with "cpuHiddenPositionX=#monitorWidth#-620" the windows wouldn't overlap any more

Now here's my code:

The if statement and how I call it and a example meter to draw:

//If
[iMoveCPU]
IfCondition = (ramHidden = 0)
IfTrueAction = [!SetVariable "cpuHiddenPositionX" "(#monitorWidth#-620)"][!Redraw]
IfFalseAction = [!SetVariable "cpuHiddenPositionX" "(#monitorWidth#-420)"][!Redraw]
Disabled = 1

//Call
LeftMouseDownAction = [!ToggleMeterGroup "HiddenCPU"],[iMoveCPU]

// one meter with cpuHiddenPositionX as variable
[pCPU0]
Meter = String
Group = HiddenCPU
MeasureName = mCPU0
MeterStyle = Style01
Text = "Core #0: %1%"
y = #cpuHiddenPositionY#
x = #cpuHiddenPositionX#
Hidden = 1
DynamicVariables = 2

I have no idea why it doesn't work please help me
Last edited by LazyLaubert on November 18th, 2017, 4:16 pm, edited 1 time in total.

Re: Help with If and !SetVariable

November 18th, 2017, 6:34 am
mak_kawa
   [210 posts]

Just a quick look...

1. IfCondition expression must be within a measure. So, [iMoveCPU] lacks "Measure=" definition header. If you want this IfCondition run always with no condition, you can insert following 2 lines.

Code: Select all

Measure=Calc
Formula=1


2. Why disabled [iMoveCPU]? Is this section is enabled somewhere in the skin?

3. In Rainmeter, "comment-out" character is ";", not "//", I think.

4. DynamicVariables option must be 0 or 1.
User avatar

Re: Help with If and !SetVariable

November 18th, 2017, 7:20 am
balala
Rainmeter Sage   [4982 posts]

mak_kawa wrote:4. DynamicVariables option must be 0 or 1.

Sorry, but not absolutely necessary. In fact I think 0 means the dynamic variables aren't set, but 1 or any greater value means they are.
Any larger value then 0 usually means true, zero means false in the logical expressions (at least as far as I know).
Try to create a simple meter which has to have set the dynamic variables and instead of adding it the DyanmicVariables=1 option, add DyanmicVariables=2 (or a greater value). You'll see it's perfectly working and doesn't even returns a error message in the log.
User avatar

Re: Help with If and !SetVariable

November 18th, 2017, 7:30 am
balala
Rainmeter Sage   [4982 posts]

LazyLaubert wrote:But when you open both things at the same time, they overlap.

mak_kawa had good observations, however I think a bit different approach also exists. Although I don't know the whole code, I have the impression that the meters could be positioned relatively to each other, this way avoiding the need of using the cpuHiddenPositionX variable.
Posting the whole code (using the [Code][/Code] tags, through the Code button), would reveal if I'm right.

Re: Help with If and !SetVariable

November 18th, 2017, 1:15 pm
LazyLaubert
   [2 posts]

Thank you guys!
I'll try it the way that mak_kawa has told me!

#######################################################################################
Update:
I finally made it :D
The problems i had to solve are:

-the missing Measure=Calc and Formula=1 also
- Disabled = 1 was wrong
- missing # -> #ramHidden# (!)
- missing DynamicVariables = 1 in [iMoveCPU]
- no [!Redraw] in [iMoveCPU]!
-missing [!Update] in the Call
-[iMoveCPU] in call is unnesessary

Return to “Help: Rainmeter Skins”



Who is online

Users browsing this forum: No registered users and 8 guests