It is currently May 1st, 2024, 6:23 pm

[Solved]Noob questions about looping and substitute

Get help with creating, editing & fixing problems with skins
oni5115
Posts: 27
Joined: October 4th, 2010, 3:33 pm

[Solved]Noob questions about looping and substitute

Post by oni5115 »

I'm new here as I just started with RainMeter yesterday. I couldn't really find any skins that are rounded quite like I had in mind so I decided to try making one. So far, things are working as I had planned, but I realized my code is going to get cluttered very quickly. I am using multiple layers in an Arc to display information, which means for every Core on the CPU there are multiple layers to handle.

In most programming languages you can use arrays/loops/functions to load/calculate variables. Is there something similar for RainMeter? I didn't quite get the "Substitution" information in the manual; a few examples would be quite helpful.

Here is an example of what I mean(Gets repeated 8 times!):

Code: Select all

[LineStart_C1_BG]
Measure=CALC
Formula=(3*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin#
[LineLength_C1_BG]
Measure=CALC
Formula=(4*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin#

[LineStart_C1_MG]
Measure=CALC
Formula=(3*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin# + (#CircleSizeBG#-#CircleSizeMG#)/2
[LineLength_C1_MG]
Measure=CALC
Formula=(4*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin# - (#CircleSizeBG#-#CircleSizeMG#)/2

[LineStart_C1_FG]
Measure=CALC
Formula=(3*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin# + (#CircleSizeBG#-#CircleSizeFG#)/2
[LineLength_C1_FG]
Measure=CALC
Formula=(4*#CircleSizeBG#)+(3*#CircleSizeGap#)+#CircleSizeMin# - (#CircleSizeBG#-#CircleSizeFG#)/2
All that changes here is the CircleSize (FG/MG/BG - Usage/Temp/Background) and the Numbers (if I had the foresight to use variables there they would be NumCores/NumSections [-1 where appropriate] - RowNumber.) NumSections being how the design is divided - halves, thirds, quarters, etc. Row number being a countdown from NumCores/NumSections... Is there an easier way to determine how far in/out each ring should be? Relative to the prior ring or something.

Anyways, I guess a picture would make more sense here. As you can see below the thin, bright arcs are the CPU usage. The wider, duller arcs are the CPU temps (on a scale of 0-127). The last layer being the BG.

How do you swap information out on a right click? I was thinking of having the Temperature layer toggle from Temps to Volts on right clicks. I'm not sure how to do that.
You do not have the required permissions to view the files attached to this post.
Last edited by oni5115 on October 12th, 2010, 6:11 am, edited 1 time in total.
Everyone loves the [url=http://db.tt/qV9oIZZ]Dropbox[/url]!
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Noob questions about looping and substitute

Post by Chewtoy »

This seems like a fairly comlicated skin, so a little deeper look at your code would be helpful so we can see what is you are doing / trying to do.

As for the relative-meter part. For the X and Y values we can use r (relative the the left / upper part of the previous meter) and R (relative to the right / bottom part of the previous meter).
As you will probably want to put those roundlines closer than R (you will see when you try it) you can use it like this X=-40R or if you want them further apart it would be something like this X=40R, or why not X=40r? Choose what you find works.

For the shifting meter part it gets a little more tricky.
There are different ways to go about this and mine is probably not the best one (alex or someone will probably make something really simple that requires a lot less code), but I would probably do something like this.

Code: Select all

[Variables]
Type=1

[MTemp]
Measure=TheMeasureYouHaveForYourTemps

[MVolts]
Measure=TheMeasureYouHaveForYourVolts

[CType]
Measure=Calc
Formula=((#Type#+1) > 1) ? 0 : #Type#+1
DynamicVariables=1

[SType]
Measure=Calc
Formula=#Type#
DynamicVariables=1
Substitute="1":"MTemp","0":"MVolts"

[Info]
Meter=Roundline
Measure=[SType]
X
Y
asda
asddf
LeftMouseUpAction=!Execute [!RainmeterWriteKeyValue Variables Type [CType]][!RainmeterRefresh]
DynamicVariables=1
This is untested. But something like that. The nice part with it is that you use the same meter to be able to show many different sort of infos. You just need to up the options in CType and add the substitutes in SType. Granted all the measures must be able to be used in a roudline in this case, use a meter and you get other things.
But anyway. Something like that perhaps. Again, this is untested as I'm unable to test it atm (not on windows). But is should work.
I don't think, therefore I'm not.
oni5115
Posts: 27
Joined: October 4th, 2010, 3:33 pm

Re: Noob questions about looping and substitute

Post by oni5115 »

The above code was part of how I decided to go about calculating the relative position - so to speak. Since RoundLines use the LineStart and LineLength values I calulated each for each ring (4 rings, 2 halves), and applied the proper values. I'm not sure if you can do a relative LineStart/Length - though maybe. You're not actually changing the X/Y coords, but the length of the lines... if that makes sense.

I guess what I am trying to do is use Substitution on the formulas so they are less messy if I need to change them. However, I cannot really figure out how to do it properly.

http://rainmeter.net/cms/Tips-SubValuesInCalc

Taking first example from there, if you modify:

Code: Select all

[InitialValue] 
Measure=Calc 
Formula=12345 
Substitute="2":"22","4":"7"
Returns: 122375, 12345, 122375

Code: Select all

[InitialValue] 
Measure=Calc 
Formula=12+345 
Substitute="2":"22","4":"7"
Returns: 357, 357, 357

Code: Select all

[InitialValue] 
Measure=Calc 
Formula=12345 
Substitute="2":"22+","4":"7"
You get:
Returns: 122+375, 12345, 497

I am trying to use substitution on a base formula so my code is easier to maintain, I just don't really know how as you can't use any +-/*() or text. Anything other than numbers returns a 0 for me. I think I can get it working though as variables seem to work ok. (ex: Substitute="2":"SomeVar+"; worked and added the variable to the number while doing the sub.)
Everyone loves the [url=http://db.tt/qV9oIZZ]Dropbox[/url]!
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Noob questions about looping and substitute

Post by Chewtoy »

No, you can't get the relative LineStart, but you can have relative positioning. Like I said, really need more of the code to see what's going on. Where things are used and all that.


In this case, the value of [GetDirectValue] would be "12345", whereas the value of [GetSubstitutedValue] would have the "2" replaced with "22" and the "4" replaced with "7". As a result, its value would instead be "122375".

As I can see you have no [GetSubstitutedValue]-like measure that reads the substituted value.
A second observation. You have a formula, and then try to substitute values that does not exist. Rainmeter reads the file from top to bottom, making all equations and measures in that order. So the formula 12+345 will be calculated before rainmeter reads that it should substitute the 2 for 22 and 4 for 7. Thus you get 357, and none of those numbers are to be substituted. If you want the 2 in 12 and the 4 in 345 to be substituted before they enter the formula, you need to pass them thru a calc before hand. That calc should only substitute the value, nothing more. And then in the calc you want the equation to take place you simply refer to the calc where the subsitution is taking place. Refer to the tips'n'tricks.

You can substitute anything for anything really. You only need to know when things get substituted. And that Calc only handles mathematics and not words or letters (exception are the ones on this page http://rainmeter.net/cms/Measures-Calc_beta ).
I don't think, therefore I'm not.
oni5115
Posts: 27
Joined: October 4th, 2010, 3:33 pm

Re: Noob questions about looping and substitute

Post by oni5115 »

Sorry it took me so long to get back. I was cleaning up the code a little bit to make it easier to copy/paste and modify for other configs (halves, quarters, different num processors, additional info layers, etc.).

The code is rather long, mostly because of the amount of repetition that is needed. Instead of using so many formulas I made made the calculations reference earlier calculations. Makes it much easier for copy/paste/replace routines this way.

Plus I should eventually be able to copy/paste entire file and swap CPU for HDD and change the Measures. POOF new plugin.

Code: Select all

[Rainmeter]
Author=Oni5115
BackgroundMode=1

[Variables]
;@include=#SKINSPATH#CircleMeters\Variables.inc
NumCores=8
NumSections=2
CPU_Temp_Min=0
CPU_Temp_Max=127
;Not Used Yet
SpeedFan_Index=3

;Variables to move to inc
CPU_Angle_Gap=20
CPU_Size_Min=40
CPU_Size_Gap=4
CPU_Size_Layer1=12
CPU_Size_layer2=10
CPU_Size_layer3=2

CPU_Color_Background=0,0,0,80
CPU_Color_Layer1=0,115,88,120
CPU_Color_Layer2=0,115,95,160
CPU_Color_Layer3=0,255,195,160

CPU_Text_Label1=1
CPU_Text_Label2=2
CPU_Text_Label3=3
CPU_Text_Label4=4
CPU_Text_Label5=5
CPU_Text_Label6=6
CPU_Text_Label7=7
CPU_Text_Label8=8
CPU_Text_Center=CPU

;Center=1, Info=2, Labels=3
CPU_Text_Gap1=2R
CPU_Text_Gap2=0R
CPU_Text_Gap3=0R

CPU_Color_Text1=0,255,195,200
CPU_Color_Text2=255,255,255,180
CPU_Color_Text3=0,255,195,190

CPU_Size_Text1=12
CPU_Size_Text2=11
CPU_Size_Text3=10

CPU_Style_Text1=BOLD
CPU_Style_Text2=BOLD
CPU_Style_Text3=BOLD

CPU_Effect_Text1=NONE
CPU_Effect_Text2=NONE
CPU_Effect_Text3=NONE

CPU_Effect_Color_Text1=0,0,0,255
CPU_Effect_Color_Text2=0,0,0,255
CPU_Effect_Color_Text3=0,0,0,255


;;;;;;;;;;;;;;;;;;;;
; MEASUREMENTS
;;;;;;;;;;;;;;;;;;;;
; Used for making the Backgrounds
[MeasureBG]
Measure=Calc
Formula=100
MaxValue=100
UpdateDivider=86400

; CPU Speed/Power
[MeasureCPU_Speed]
Measure=PLUGIN
Plugin=Plugins/PowerPlugin.dll
PowerState=MHZ

[MeasureCPU_C0]
Measure=CPU
Processor=0
[MeasureCPU_C1]
Measure=CPU
Processor=1
[MeasureCPU_C2]
Measure=CPU
Processor=2
[MeasureCPU_C3]
Measure=CPU
Processor=3
[MeasureCPU_C4]
Measure=CPU
Processor=4
[MeasureCPU_C5]
Measure=CPU
Processor=5
[MeasureCPU_C6]
Measure=CPU
Processor=6
[MeasureCPU_C7]
Measure=CPU
Processor=7
[MeasureCPU_C8]
Measure=CPU
Processor=8

; CPU Temps
[MeasureCPU_Temp_C1]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=3
[MeasureCPU_Temp_C2]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=4
[MeasureCPU_Temp_C3]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=5
[MeasureCPU_Temp_C4]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=6
[MeasureCPU_Temp_C5]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=7
[MeasureCPU_Temp_C6]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=8
[MeasureCPU_Temp_C7]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=9
[MeasureCPU_Temp_C8]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=10

; CPU Temps - bar calculations
[MeasureCPU_Temp_Bar_C1]
Measure=CALC
Formula=([MeasureCPU_Temp_C1]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C2]
Measure=CALC
Formula=([MeasureCPU_Temp_C2]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C3]
Measure=CALC
Formula=([MeasureCPU_Temp_C3]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C4]
Measure=CALC
Formula=([MeasureCPU_Temp_C4]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C5]
Measure=CALC
Formula=([MeasureCPU_Temp_C5]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C6]
Measure=CALC
Formula=([MeasureCPU_Temp_C6]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C7]
Measure=CALC
Formula=([MeasureCPU_Temp_C7]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1
[MeasureCPU_Temp_Bar_C8]
Measure=CALC
Formula=([MeasureCPU_Temp_C8]-#CPU_Temp_Min#) /#CPU_Temp_Max#
DynamicVariables=1

;;;;;;;;;;;;;;;;;;;;
; Calculations
;;;;;;;;;;;;;;;;;;;;

[NumRows2]
Measure=CALC
Formula=CEIL(#NumCores#/#NumSections#)
[Radius]
Measure=CALC
Formula=(([NumRows2]*#CPU_Size_Layer1#)+(([NumRows2]-1)*#CPU_Size_Gap#)+#CPU_Size_Min#)
DynamicVariables=1
[Circumference]
Measure=CALC
Formula=[Radius]*2
DynamicVariables=1

; Used to determine start/angle of arcs.
[SectionSize]
Measure=CALC
Formula=((360/#NumSections#)-#CPU_Angle_Gap#) * (PI/180)
[StartAngle_Section1]
Measure=CALC
Formula=(-90+(#CPU_Angle_Gap#/2)) * (PI/180)
[StartAngle_Section2]
Measure=CALC
Formula=([StartAngle_Section1] + [SectionSize]) +((#CPU_Angle_Gap#)*(PI/180))
DynamicVariables=1

; Used to determine the start/length of arcs.
; Row 1
[LineStart_Row1_Layer1]
Measure=CALC
Formula=#CPU_Size_Min#
[LineStart_Row1_Layer2]
Measure=CALC
Formula=[LineStart_Row1_Layer1] + (#CPU_Size_Layer1#-#CPU_Size_layer2#)/2
DynamicVariables=1
[LineStart_Row1_Layer3]
Measure=CALC
Formula=[LineStart_Row1_Layer2] + (#CPU_Size_Layer2#-#CPU_Size_layer3#)/2
DynamicVariables=1

[LineLength_Row1_Layer1]
Measure=CALC
Formula=[LineStart_Row1_Layer1] + #CPU_Size_Layer1#
DynamicVariables=1
[LineLength_Row1_Layer2]
Measure=CALC
Formula=[LineStart_Row1_Layer2] + #CPU_Size_Layer2#
DynamicVariables=1
[LineLength_Row1_Layer3]
Measure=CALC
Formula=[LineStart_Row1_Layer3] + #CPU_Size_Layer3#
DynamicVariables=1


; Row2
[LineStart_Row2_Layer1]
Measure=CALC
Formula=[LineStart_Row1_Layer1] + #CPU_Size_Layer1# + #CPU_Size_Gap#
DynamicVariables=1
[LineStart_Row2_Layer2]
Measure=CALC
Formula=[LineStart_Row2_Layer1] + (#CPU_Size_Layer1#-#CPU_Size_layer2#)/2
DynamicVariables=1
[LineStart_Row2_Layer3]
Measure=CALC
Formula=[LineStart_Row2_Layer2] + (#CPU_Size_Layer2#-#CPU_Size_layer3#)/2
DynamicVariables=1

[LineLength_Row2_Layer1]
Measure=CALC
Formula=[LineStart_Row2_Layer1] + #CPU_Size_Layer1#
DynamicVariables=1
[LineLength_Row2_Layer2]
Measure=CALC
Formula=[LineStart_Row2_Layer2] + #CPU_Size_Layer2#
DynamicVariables=1
[LineLength_Row2_Layer3]
Measure=CALC
Formula=[LineStart_Row2_Layer3] + #CPU_Size_Layer3#
DynamicVariables=1

; Row3
[LineStart_Row3_Layer1]
Measure=CALC
Formula=[LineStart_Row2_Layer1] + #CPU_Size_Layer1# + #CPU_Size_Gap#
DynamicVariables=1
[LineStart_Row3_Layer2]
Measure=CALC
Formula=[LineStart_Row3_Layer1] + (#CPU_Size_Layer1#-#CPU_Size_layer2#)/2
DynamicVariables=1
[LineStart_Row3_Layer3]
Measure=CALC
Formula=[LineStart_Row3_Layer2] + (#CPU_Size_Layer2#-#CPU_Size_layer3#)/2
DynamicVariables=1

[LineLength_Row3_Layer1]
Measure=CALC
Formula=[LineStart_Row3_Layer1] + #CPU_Size_Layer1#
DynamicVariables=1
[LineLength_Row3_Layer2]
Measure=CALC
Formula=[LineStart_Row3_Layer2] + #CPU_Size_Layer2#
DynamicVariables=1
[LineLength_Row3_Layer3]
Measure=CALC
Formula=[LineStart_Row3_Layer3] + #CPU_Size_Layer3#
DynamicVariables=1


; Row2
[LineStart_Row2_Layer1]
Measure=CALC
Formula=[LineStart_Row1_Layer1] + #CPU_Size_Layer1# + #CPU_Size_Gap#
DynamicVariables=1
[LineStart_Row2_Layer2]
Measure=CALC
Formula=[LineStart_Row2_Layer1] + (#CPU_Size_Layer1#-#CPU_Size_layer2#)/2
DynamicVariables=1
[LineStart_Row2_Layer3]
Measure=CALC
Formula=[LineStart_Row2_Layer2] + (#CPU_Size_Layer2#-#CPU_Size_layer3#)/2
DynamicVariables=1

[LineLength_Row2_Layer1]
Measure=CALC
Formula=[LineStart_Row2_Layer1] + #CPU_Size_Layer1#
DynamicVariables=1
[LineLength_Row2_Layer2]
Measure=CALC
Formula=[LineStart_Row2_Layer2] + #CPU_Size_Layer2#
DynamicVariables=1
[LineLength_Row2_Layer3]
Measure=CALC
Formula=[LineStart_Row2_Layer3] + #CPU_Size_Layer3#
DynamicVariables=1

; Row4
[LineStart_Row4_Layer1]
Measure=CALC
Formula=[LineStart_Row3_Layer1] + #CPU_Size_Layer1# + #CPU_Size_Gap#
DynamicVariables=1
[LineStart_Row4_Layer2]
Measure=CALC
Formula=[LineStart_Row4_Layer1] + (#CPU_Size_Layer1#-#CPU_Size_layer2#)/2
DynamicVariables=1
[LineStart_Row4_Layer3]
Measure=CALC
Formula=[LineStart_Row4_Layer2] + (#CPU_Size_Layer2#-#CPU_Size_layer3#)/2
DynamicVariables=1

[LineLength_Row4_Layer1]
Measure=CALC
Formula=[LineStart_Row4_Layer1] + #CPU_Size_Layer1#
DynamicVariables=1
[LineLength_Row4_Layer2]
Measure=CALC
Formula=[LineStart_Row4_Layer2] + #CPU_Size_Layer2#
DynamicVariables=1
[LineLength_Row4_Layer3]
Measure=CALC
Formula=[LineStart_Row4_Layer3] + #CPU_Size_Layer3#
DynamicVariables=1


;;;;;;;;;;;;;;;;;;;;
; METERS
;;;;;;;;;;;;;;;;;;;;

; Background based on Max Circle Size
[MeterBackground]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=0
RotationAngle=6.283183
LineLength=[Radius]
LineColor=#CPU_Color_Background#
Solid=1
AntiAlias=1
DynamicVariables=1

;;;;;;;;;;;;;;;;;;;;;
;Text Labels
;;;;;;;;;;;;;;;;;;;;;
[Meter_Label1]
Meter=STRING
X=[Radius]
Y=0
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label1#
DynamicVariables=1

[Meter_Label2]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label2#
DynamicVariables=1

[Meter_Label3]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label3#
DynamicVariables=1

[Meter_Label4]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label4#
DynamicVariables=1

[Meter_Label_Center1]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap1#
FontColor=#CPU_Color_Text1#
FontSize=#CPU_Size_Text1#
StringStyle=#CPU_Style_Text1#
StringEffect=#CPU_Effect_Text1#
FontEffectColor=#CPU_Effect_Color_Text1#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Center#
DynamicVariables=1
LeftMouseDownAction=!Execute ["taskmgr"]

[Meter_Label_Center2]
Meter=STRING
MeasureName=MeasureCPU_C0
X=[Radius]
Y=#CPU_Text_Gap2#
FontColor=#CPU_Color_Text2#
FontSize=#CPU_Size_Text2#
StringStyle=#CPU_Style_Text2#
StringEffect=#CPU_Effect_Text2#
FontEffectColor=#CPU_Effect_Color_Text2#
StringAlign=Center
AntiAlias=1
Text=%1%
NumOfDecimals=1
DynamicVariables=1
LeftMouseDownAction=!Execute ["taskmgr"]

[Meter_Label_Center3]
Meter=STRING
MeasureName=MeasureCPU_Temp_C1
X=[Radius]
Y=#CPU_Text_Gap2#
FontColor=#CPU_Color_Text2#
FontSize=#CPU_Size_Text2#
StringStyle=#CPU_Style_Text2#
StringEffect=#CPU_Effect_Text2#
FontEffectColor=#CPU_Effect_Color_Text2#
StringAlign=Center
AntiAlias=1
Text="%1 °c"
NumOfDecimals=0
DynamicVariables=1
LeftMouseDownAction=!Execute ["taskmgr"]

[Meter_Label_Center4]
Meter=STRING
MeasureName=MeasureCPU_Speed
X=[Radius]
Y=#CPU_Text_Gap2#
FontColor=#CPU_Color_Text2#
FontSize=#CPU_Size_Text2#
StringStyle=#CPU_Style_Text2#
StringEffect=#CPU_Effect_Text2#
FontEffectColor=#CPU_Effect_Color_Text2#
StringAlign=Center
AntiAlias=1
Text=%1
NumOfDecimals=2
Scale=1000
DynamicVariables=1
LeftMouseDownAction=!Execute ["taskmgr"]

[Meter_Label5]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap1#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label5#
DynamicVariables=1

[Meter_Label6]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label6#
DynamicVariables=1

[Meter_Label7]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label7#
DynamicVariables=1

[Meter_Label8]
Meter=STRING
X=[Radius]
Y=#CPU_Text_Gap3#
FontColor=#CPU_Color_Text3#
FontSize=#CPU_Size_Text3#
StringStyle=#CPU_Style_Text3#
StringEffect=#CPU_Effect_Text3#
FontEffectColor=#CPU_Effect_Color_Text3#
StringAlign=Center
AntiAlias=1
Text=#CPU_Text_Label8#
DynamicVariables=1


;;;;;;;;;;;;;;;;;;;;;
;SECTION 1
;;;;;;;;;;;;;;;;;;;;;
; Section 1, Row 1
[Meter_Section1_Row1_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer1]
LineLength=[LineLength_Row1_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row1_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C4
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer2]
LineLength=[LineLength_Row1_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row1_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C4
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer3]
LineLength=[LineLength_Row1_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 2
[Meter_Section1_Row2_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer1]
LineLength=[LineLength_Row2_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row2_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C3
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer2]
LineLength=[LineLength_Row2_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row2_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C3
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer3]
LineLength=[LineLength_Row2_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 3
[Meter_Section1_Row3_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer1]
LineLength=[LineLength_Row3_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row3_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C2
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer2]
LineLength=[LineLength_Row3_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row3_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C2
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer3]
LineLength=[LineLength_Row3_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 2
[Meter_Section1_Row4_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer1]
LineLength=[LineLength_Row4_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row4_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C1
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer2]
LineLength=[LineLength_Row4_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section1_Row4_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C1
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section1]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer3]
LineLength=[LineLength_Row4_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1


;;;;;;;;;;;;;;;;;;;;;
;SECTION 2
;;;;;;;;;;;;;;;;;;;;;
; Section 2, Row 1
[Meter_Section2_Row1_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer1]
LineLength=[LineLength_Row1_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row1_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C4
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer2]
LineLength=[LineLength_Row1_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row1_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C4
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row1_Layer3]
LineLength=[LineLength_Row1_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 2
[Meter_Section2_Row2_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer1]
LineLength=[LineLength_Row2_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row2_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C3
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer2]
LineLength=[LineLength_Row2_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row2_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C3
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row2_Layer3]
LineLength=[LineLength_Row2_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 3
[Meter_Section2_Row3_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer1]
LineLength=[LineLength_Row3_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row3_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C2
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer2]
LineLength=[LineLength_Row3_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row3_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C2
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row3_Layer3]
LineLength=[LineLength_Row3_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1

; Section 1, Row 2
[Meter_Section2_Row4_Layer1]
Meter=ROUNDLINE
MeasureName=MeasureBG
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer1]
LineLength=[LineLength_Row4_Layer1]
LineColor=#CPU_Color_Layer1#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row4_Layer2]
Meter=ROUNDLINE
MeasureName=MeasureCPU_Temp_Bar_C1
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer2]
LineLength=[LineLength_Row4_Layer2]
LineColor=#CPU_Color_Layer2#
Solid=1
AntiAlias=1
DynamicVariables=1
[Meter_Section2_Row4_Layer3]
Meter=ROUNDLINE
MeasureName=MeasureCPU_C1
W=[Circumference]
H=[Circumference]
StartAngle=[StartAngle_Section2]
RotationAngle=[SectionSize]
LineStart=[LineStart_Row4_Layer3]
LineLength=[LineLength_Row4_Layer3]
LineColor=#CPU_Color_Layer3#
Solid=1
AntiAlias=1
DynamicVariables=1
8-)

Edit: I really don't think there is any way to shrink the line count; but at least now the code is a bit more manageable.
Everyone loves the [url=http://db.tt/qV9oIZZ]Dropbox[/url]!
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Noob questions about looping and substitute

Post by Alex2539 »

Chewtoy wrote:For the shifting meter part it gets a little more tricky.
There are different ways to go about this and mine is probably not the best one (alex or someone will probably make something really simple that requires a lot less code), but I would probably do something like this.

Code: Select all

[Variables]
Type=1

[MTemp]
Measure=TheMeasureYouHaveForYourTemps

[MVolts]
Measure=TheMeasureYouHaveForYourVolts

[CType]
Measure=Calc
Formula=((#Type#+1) > 1) ? 0 : #Type#+1
DynamicVariables=1

[SType]
Measure=Calc
Formula=#Type#
DynamicVariables=1
Substitute="1":"MTemp","0":"MVolts"

[Info]
Meter=Roundline
Measure=[SType]
X
Y
asda
asddf
LeftMouseUpAction=!Execute [!RainmeterWriteKeyValue Variables Type [CType]][!RainmeterRefresh]
DynamicVariables=1
You're right, I'm totally coming in here and stealing your thunder. First and foremost, if all you're doing with CType is using it to switch #Type# between 1 and 0, then you coulld have gotten rid of it and just done the switch within RainmeterWriteKeyValue. Like RainmeterSetVariable, if you put the value you want to use within parenthesis, it will assume that it's a formula and perform the calculation before assigning a value. So instead of the CType measure, you could just have used "[!RainmeterWriteKeyValue Variable Type (#Type#=0)]". That's kind of irrelevant though since overall the switch wasn't working anyway.

When I tested that out, it seemed that Rainmeter had no problem reading the MeasureName from a dynamic variable, but it refused to change the it afterward. Because all of the measures (at least the calcs) always start at 0 at the very start, the [Info] would only ever measure MVolts.

To fix it, I added a variable, Ring1, which would hold the name of the measure for the Roundline to use and pointed its MeasureName to that variable. Then, when you click it to change the measure, it also writes the value of SType to Ring1 (for some reason that I can't remember I renamed SType to MeasRing1 in my example, but they do the same thing). Then the skin is refreshed and the right measure is read. It's a little bit more roundabout than I would like, but it works.

As for lining up the roundlines properly, there's a very simple way to do it. Just make the X, Y width and height the same for all of them. Then in each roundline all you need to set are the LineStart and LineLength values to change the size of them. When you set a width and a height for a Roundline, it assumes that the center of the circle will be the center of the box you specified, regardless of the sizes. Also, StartAngle and RotationAngle will also both line up for all of the rings.

Here's an example of all of this working together. There are three rings and 6 measures being read. Well... It's really just two measures that I tripled, but it's the same idea. One set of measures will make the rings bounce back and forth between full and empty, the other will have them fill up all the way and then reset, and clicking the skin will switch between them. It should be easy enough to expand on it: just duplicate the sections as needed and tweak the numbers to suit your needs.

Code: Select all

[Rainmeter]
Update=100

[Variables]
Type=1.000000
Ring1=Meas1
Ring2=Meas2
Ring3=Meas3

[CheckType]
Measure=Calc
Formula=#Type#
DynamicVariables=1

[Meas1]
Measure=Calc
Formula=Counter % 25
MaxValue=25

[Meas2]
Measure=Calc
Formula=Counter % 25
MaxValue=25

[Meas3]
Measure=Calc
Formula=Counter % 25
MaxValue=25

[Meas4]
Measure=Calc
Formula=COS((Counter % 30)/30*PI*2)+1
MaxValue=2

[Meas5]
Measure=Calc
Formula=COS((Counter % 30)/30*PI*2)+1
MaxValue=2

[Meas6]
Measure=Calc
Formula=COS((Counter % 30)/30*PI*2)+1
MaxValue=2

[MeasRing1]
Measure=Calc
Formula=#Type#
Substitute=".0":"","1":"Meas4","0":"Meas1"
DynamicVariables=1

[MeasRing2]
Measure=Calc
Formula=#Type#
Substitute=".0":"","0":"Meas2","1":"Meas5"

[MeasRing3]
Measure=Calc
Formula=#Type#
Substitute=".0":"","0":"Meas3","1":"Meas6"

[Ring1]
Meter=Roundline
MeasureName=#Ring1#
W=300
H=300
LineStart=135
LineLength=150
LineColor=0,128,128,128
Solid=1
DynamicVariables=1
SolidColor=0,0,0,1
LeftMouseUpAction=!Execute [!RainmeterWriteKeyValue Variables Type (#Type#=0)][!RainmeterWriteKeyValue Variables Ring1 [MeasRing1]][!RainmeterWriteKeyValue Variables Ring2 [MeasRing2]][!RainmeterWriteKeyValue Variables Ring3 [MeasRing3]][!RainmeterRefresh]
AntiAlias=1

[Ring2]
Meter=Roundline
MeasureName=#Ring2#
W=300
H=300
LineStart=115
LineLength=130
LineColor=0,128,128,128
Solid=1
DynamicVariables=1
AntiAlias=1

[Ring3]
Meter=Roundline
MeasureName=#Ring3#
W=300
H=300
LineStart=95
LineLength=110
LineColor=0,128,128,128
Solid=1
DynamicVariables=1
AntiAlias=1
Also, there's one other thing I would like to address:
oni5115 wrote:In most programming languages you can use arrays/loops/functions to load/calculate variables. Is there something similar for RainMeter?
It should be stressed that Rainmeter is not, nor does it use a programming language. There is no program flow, there are no data types and there are barely even variables. It's best if you think about it as a list of settings. Each setting is given a value in the .ini file and Rainmeter reads through them to decide what is shown on the screen. While some of the settings, like the Calc measure's "Formula" setting, can be fairly complex, they are settings nonetheless. The Calc measure, Bangs and Dynamic Variables all help to blur this fact by introducing a much more complex and dynamic aspect to Rainmeter, but they do not a programming language make. If you are a programmer, then some of the logic and lateral thinking you're used to could be applied to creating a Rainmeter skin, especially once you start getting complicated, but you should never pursue the conventions or techniques used in programming languages since they will largely not apply.

That doesn't really have anything to do with your problem, and it's not really directed at you personally. It's just something I think should be put out on the table whenever it comes up.
ImageImageImageImage
oni5115
Posts: 27
Joined: October 4th, 2010, 3:33 pm

Re: Noob questions about looping and substitute

Post by oni5115 »

As for lining up the roundlines properly, there's a very simple way to do it. Just make the X, Y width and height the same for all of them. Then in each roundline all you need to set are the LineStart and LineLength values to change the size of them. When you set a width and a height for a Roundline, it assumes that the center of the circle will be the center of the box you specified, regardless of the sizes. Also, StartAngle and RotationAngle will also both line up for all of the rings.
Yeah that is exactly how I got it working. I was just hoping there might be a way to do it that makes the code smaller. Good to know I was doing it right though. Knowing the limitations is important.

When I run the example code on the bottom I get "Unknown !bang: !RainmeterWriteKeyValue" when I left click on it.
Everyone loves the [url=http://db.tt/qV9oIZZ]Dropbox[/url]!
User avatar
JamesAC
Developer
Posts: 318
Joined: July 14th, 2009, 5:57 pm

Re: Noob questions about looping and substitute

Post by JamesAC »

oni5115 wrote: Yeah that is exactly how I got it working. I was just hoping there might be a way to do it that makes the code smaller. Good to know I was doing it right though. Knowing the limitations is important.

When I run the example code on the bottom I get "Unknown !bang: !RainmeterWriteKeyValue" when I left click on it.
My guess is you are running an old version of Rainmeter (1.2??) You need to upgrade to the 1.3 RC to use !RainmeterWriteKeyValue
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
Quis custodiet ipsos custodes?
oni5115
Posts: 27
Joined: October 4th, 2010, 3:33 pm

Re: Noob questions about looping and substitute

Post by oni5115 »

Indeed I am. Using 1.2 since the 1.3's are still beta if I am not mistaken.
Everyone loves the [url=http://db.tt/qV9oIZZ]Dropbox[/url]!
User avatar
JamesAC
Developer
Posts: 318
Joined: July 14th, 2009, 5:57 pm

Re: Noob questions about looping and substitute

Post by JamesAC »

oni5115 wrote:Indeed I am. Using 1.2 since the 1.3's are still beta if I am not mistaken.
You are correct although the latest version is the release candidate for the full release, and is just as stable as 1.2 really.

I would definitely recommend the upgrade :D
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
Quis custodiet ipsos custodes?