It is currently April 26th, 2024, 4:44 am

Calculating greatest number in a range.

Get help with creating, editing & fixing problems with skins
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Calculating greatest number in a range.

Post by StArL0rd84 »

We have the max function that calculates the greatest of two values (X and Y)
https://docs.rainmeter.net/manual/formulas/

Code: Select all

[GreatestNumber]
 Measure=Calc
 Formula=Max(30, 20)
But is there a way to formulate it different to include more values?
My skin has a background that needs to be dynamic in size to accommodate different widths of text.


EDIT:
Found a crude way to trick it using more measures.
But would like a less resource heavy solution still.

Code: Select all

[GreatestNumber1]
Measure=Calc
Formula=Max(30, 20)
[GreatestNumber2]
Measure=Calc
Formula=Max(40, 50)
 
[GreatestNumber3]
Measure=Calc
Formula=Max([GreatestNumber1], [GreatestNumber2])
DynamicVariables=1
Last edited by StArL0rd84 on June 17th, 2020, 4:05 pm, edited 1 time in total.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Calculating greatest number in a range.

Post by ikarus1969 »

There are variuos ways.
What i do when i need to compare more than 2 values is to nest the MAX-function:

Code: Select all

[BiggestNumber]
Measure=Calc
Formula=Max(30, MAX(MAX(23.2, 17), MAX(70, 10)))
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Calculating greatest number in a range.

Post by StArL0rd84 »

Clever man. thanks.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Calculating greatest number in a range.

Post by ikarus1969 »

StArL0rd84 wrote: June 17th, 2020, 4:07 pm Clever man. thanks.
Glad to help.