It is currently October 13th, 2024, 4:52 pm

Change Variable dynamically with if function

General topics related to Rainmeter.
User avatar
Tezz95
Posts: 28
Joined: April 18th, 2023, 1:55 pm

Change Variable dynamically with if function

Post by Tezz95 »

Hi, I am new to Rainmeter. I am making a skin for my personal use and I don't know how to deal with the following problem.
I have three variables, first one is named 'size', which changes dynamically by scrolling the mouse. I want to change the second (name: W) and third (name: Gap) variables with an if condition depending on the first variable. Changes should be done by following values:
Image
Asper the image If 'size' is 5.5, 'W' should be 6 and 'Gap' should be 5 and if 'size' is 2, 'W' should be 2 and 'Gap' should be 2.
Please help with how to change the second and third variables if the first one changes.
Thanks in advance.
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2746
Joined: March 23rd, 2015, 5:26 pm

Re: Change Variable dynamically with if function

Post by SilverAzide »

Tezz95 wrote: April 19th, 2023, 2:37 pm
You might want to read the manual. To answer your questions, you'll want to read about IfConditions and the !SetVariable bang.

You'll need to use these in conjunction with some measure that will react to whatever you are doing. The IfCondition docs have an example that uses !SetOption bangs, so you would do something similar using !SetVariable bangs instead.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Variable dynamically with if function

Post by balala »

Tezz95 wrote: April 19th, 2023, 2:37 pm I want to change the second (name: W) and third (name: Gap) variables with an if condition depending on the first variable. Changes should be done by following values:
There is a small inconsistency in the provided data. What should you get for both functions, when size=1? Because both functions are shown should be 2 when size is 1 on the 10th column, but should be 1 on the 12th column. Plase let us (me) know what value should the function return for size=1, because it matters a lot.
User avatar
Tezz95
Posts: 28
Joined: April 18th, 2023, 1:55 pm

Re: Change Variable dynamically with if function

Post by Tezz95 »

There is a small inconsistency in the provided data. What should you get for both functions, when size=1? Because both functions are shown should be 2 when size is 1 on the 10th column, but should be 1 on the 12th column. Plase let us (me) know what value should the function return for size=1, because it matters a lot.
Please ignore the previous attached image. There are errors in the image and I am sorry for that.
Please check the new image.
Screenshot 2023-04-20 073832.png
Asper the image If 'size' is 5.5, 'W' should be 6 and 'Gap' should be 5 and if 'size' is 2, 'W' should be 2 and 'Gap' should be 2. Accordingly when size=1 'W' and 'Gap' both should be 1.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Variable dynamically with if function

Post by balala »

Tezz95 wrote: April 20th, 2023, 2:25 am Please ignore the previous attached image. There are errors in the image and I am sorry for that.
Please check the new image.Screenshot 2023-04-20 073832.png
Asper the image If 'size' is 5.5, 'W' should be 6 and 'Gap' should be 5 and if 'size' is 2, 'W' should be 2 and 'Gap' should be 2. Accordingly when size=1 'W' and 'Gap' both should be 1.
There is no need of conditions. This can be done easily using the Floor and Ceil functions. For instance:

Code: Select all

[Variables]
size=1

[MeasureW]
Measure=Calc
Formula=( Ceil ( #size# ))

[MeasureGap]
Measure=Calc
Formula=( Floor ( #size# ))
User avatar
Tezz95
Posts: 28
Joined: April 18th, 2023, 1:55 pm

Re: Change Variable dynamically with if function

Post by Tezz95 »

balala wrote: April 20th, 2023, 5:46 am There is no need of conditions. This can be done easily using the Floor and Ceil functions. For instance:
Thank you. The code working perfectly. Learnt new things. Didn't know about these functions. :great:
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Variable dynamically with if function

Post by balala »

Tezz95 wrote: April 20th, 2023, 8:01 amThe code working perfectly. Learnt new things. Didn't know about these functions. :great:
Great! There always are many things to be learnt.