It is currently November 13th, 2018, 3:37 am

Help with If and !SetVariable

Help with creating, editing & fixing problems with skins
LazyLaubert
Posts: 2
Joined: November 18th, 2017, 12:33 am

Help with If and !SetVariable

LazyLaubert » November 18th, 2017, 12:57 am

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.
mak_kawa
Posts: 219
Joined: December 30th, 2015, 9:47 am

Re: Help with If and !SetVariable

mak_kawa » November 18th, 2017, 6:34 am

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
balala
Rainmeter Sage
Posts: 6971
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with If and !SetVariable

balala » November 18th, 2017, 7:20 am

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
balala
Rainmeter Sage
Posts: 6971
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with If and !SetVariable

balala » November 18th, 2017, 7:30 am

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 tags, through the Code button), would reveal if I'm right.
LazyLaubert
Posts: 2
Joined: November 18th, 2017, 12:33 am

Re: Help with If and !SetVariable

LazyLaubert » November 18th, 2017, 1:15 pm

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