It is currently June 18th, 2024, 8:54 am

## Quick question regarding calc logic [Solved]

Get help with creating, editing & fixing problems with skins
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

### Quick question regarding calc logic [Solved]

Is it possible to do a string of logic commands in one calc?
e.g if number is higher than 5 AND equal to 10 multiply number by 2.
My question is not how to do it, it is if it works in rainmeter.
Here is the example in calc format if you do not understand my explanation. Sky blue = the first logic command, red = the second one.
#Number#>5 ? #Number#=10 ? #Number#*2 : #Number# : #Number#
Last edited by Aarowaim on August 16th, 2010, 8:51 pm, edited 1 time in total.
Away for a while :(
Programming isn't a hobby, it's a lifestyle choice.
[url=http://www.rainmeter.net/forum/viewtopic.php?f=83&t=1207][b]T34M V.1.5.0.|2[/b][/url] <----I'ts l33t, look it up

Coding Skills: [color=#00FFFF]4.5[/color]
Image Editing: [color=#00FFFF]3[/color]
Knowledge: [color=#00FFFF]4.5[/color]
Technical Skills: [color=#00FFFF]3[/color]
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

### Re: Quick question regarding calc logic

I cannot confirm or deny if it works in Rainmeter.
But I believe it should be written as:
((#Number#>5) & (#Number#=10)) ? #Number#*2 : #Number#
(Paranthesis shouldn't be necessary, just for organization on my part)

Also, if you're looking for this exact case, you only need #Number#=10
The #Number#>5 AND #Number#=10 would boil down to just #Number#=10
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

### Re: Quick question regarding calc logic

Yes, I understand that my example was a little flawed and could have been shortened, but I was using it purely as an example. now the reason I didn't use & is because, let's say I wanted it to do this :
#Number#>5 ? #Number#=10 ? #Number#*2 : #Number#/2 : #Number#
Would this be possible?
Away for a while :(
Programming isn't a hobby, it's a lifestyle choice.
[url=http://www.rainmeter.net/forum/viewtopic.php?f=83&t=1207][b]T34M V.1.5.0.|2[/b][/url] <----I'ts l33t, look it up

Coding Skills: [color=#00FFFF]4.5[/color]
Image Editing: [color=#00FFFF]3[/color]
Knowledge: [color=#00FFFF]4.5[/color]
Technical Skills: [color=#00FFFF]3[/color]
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

### Re: Quick question regarding calc logic

I see what you mean.
I can't say either way if it'll work or not.
Parantheses may be necessary for it to work properly.

I'll test it tomorrow if you don't test it by then.

A simple way would be:
[Variable]
Number=10

[msCalc]
Measure=Calc
Formula=#Number#>5 ? (#Number#=10 ? #Number#*2 : #Number#/2) : #Number#

[mtString]
Meter=String
MeasureName=msCalc
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

### Re: Quick question regarding calc logic

Aarowaim wrote:Yes, I understand that my example was a little flawed and could have been shortened, but I was using it purely as an example. now the reason I didn't use & is because, let's say I wanted it to do this :
#Number#>5 ? #Number#=10 ? #Number#*2 : #Number#/2 : #Number#
Would this be possible?
No. That won't work.
You could do this though:
#Number# > 5 ? ((#Number# = 10) ? (#Number# * 2) : (#Number# / 2)) : #Number#
I don't think, therefore I'm not.
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

### Re: Quick question regarding calc logic

Ok, I understand now. So if I want to do logic inside a logic equation, I need to enclose the second logic equation as if it were a seperate step in the equation. Thank you very much for your help.
Away for a while :(
Programming isn't a hobby, it's a lifestyle choice.
[url=http://www.rainmeter.net/forum/viewtopic.php?f=83&t=1207][b]T34M V.1.5.0.|2[/b][/url] <----I'ts l33t, look it up

Coding Skills: [color=#00FFFF]4.5[/color]
Image Editing: [color=#00FFFF]3[/color]
Knowledge: [color=#00FFFF]4.5[/color]
Technical Skills: [color=#00FFFF]3[/color]
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

### Re: Quick question regarding calc logic

Aarowaim wrote:Ok, I understand now. So if I want to do logic inside a logic equation, I need to enclose the second logic equation as if it were a seperate step in the equation. Thank you very much for your help.
It's just like regular math.
If you want to know what 3 / 12 is, but you want to use multiplication to get the 12, you can't write 3 / 6 * 2 as that would be calculated as 3/6 = 0.5 * 2 = 1, while what you really wanted was 3 / (6*2) which equals 0.25
Parenthesis has the power! So to speak...
I don't think, therefore I'm not.
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

### Re: Quick question regarding calc logic

Chewtoy wrote: It's just like regular math....
....Parenthesis has the power! So to speak...
Thank you, that is indeed as I understood. It works btw.
Away for a while :(
Programming isn't a hobby, it's a lifestyle choice.
[url=http://www.rainmeter.net/forum/viewtopic.php?f=83&t=1207][b]T34M V.1.5.0.|2[/b][/url] <----I'ts l33t, look it up

Coding Skills: [color=#00FFFF]4.5[/color]