It is currently April 26th, 2024, 2:48 am

Detecting Number of cores a processor has, and switches too!

Get help with creating, editing & fixing problems with skins
es187
Posts: 2
Joined: October 12th, 2010, 2:00 am

Detecting Number of cores a processor has, and switches too!

Post by es187 »

So, my first question is, plain and simple, is there a function to do such a thing (I would imagine so) if not, then a manual input would do just fine for this skin.

Now, even if the skin were to be given this number, this does not accomplish the function at hand. I want certain lines (namely the CPU lines, for when that certain core does not exist) to be hidden, as well as the text that is associated with it, so, here is my current code that does not work, (#NumCores# is a pre-defined value, for this test, I set it to 1). It's also worth noting that I set the calc values to decimals, to eliminate any problems with < >, as opposed to <= =>, however, it should return with a maximum range of .99<X<2.01. Also, a disclaimer: Although it is not my first time working with switches, it is my first time working with them in Rainmeter, so I'm not even sure about the IfElse function (the manual was very lacking in description :| ) so, all the switch functions I've adapted from other forum posts.

Code: Select all

[[MeasureNumOfCPU2]
Measure=Calc
Formula=#NumCores#
IfBelowValue=1.99
IfBelowAction=0
IfElse
IfElseAction=1

;A few other, unrelated things in here

[MeterCPU2VisualBar] ;displays a line at a calculated, fluctuating position.
Meter=Image
MeasureName=MeasureNumOfCPU2
SolidColor=#graph.line#
X=0
Y=[MeasureCPU2OverallHeight]
W=214
H=1
DynamicVariables=1
Hidden=%1 ;If the problem wasn't above, this would probably be it, I don't think that measures can be used
;         down here, can they?
If anyone could help, this would be the last thing to do before unleashing Version 1.0 unto the world! :D
What's this button do?
I dunno, push it!
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Detecting Number of cores a processor has, and switches too!

Post by jsmorley »

Well, to start with there is no IfElse function in Rainmeter whatsoever.

IfElse
IfElseAction=1

Neither of these exist in any way. There is IfAboveAction, IfBelowAction and IfEqualAction only.

In fact, it is risky to think of IfxxxxAction as a "switch" or "case" statement. It's not really.

They way they work is that the definition of IfxxxxValue is evaluated against the result of the measure it is in. If the answer is "true" then the action associated is fired. ONCE. It will not fire again until it changes from true to false and then back to true again. If the answer is false, it obviously doesn't fire the action. There is no way using IfxxxxActions to do something like:

If ReturnValue = 1 then
do this
if ReturnValue = 2 then
do that
Else
do other

There are a lot of clever things you can do using a combination of Equal/Above/Below in these statements, but to call it a "switch" statement is going to lead you down a dangerous path.