It is currently April 27th, 2024, 5:41 pm

If/Else in Rainmeter

Get help with creating, editing & fixing problems with skins
DonDemon
Posts: 5
Joined: February 21st, 2011, 8:12 pm

If/Else in Rainmeter

Post by DonDemon »

Hey guys,

I was making my iTunes config today, but I came along a problem I didn't know how to solve.

Currently I have this: Text="by %1",
but what I want is this (in pseudocode):

if (GetCurrentTrackArtist = NULL)
{
Text=""
}
else
{
Text="by %1"
}

So basically what I want is that when GetCurrentTrackArtist gives no value, I don't want it to show "by" on my desktop.
Any ideas?
User avatar
JoBu
Posts: 271
Joined: February 16th, 2011, 12:46 am
Location: California

Re: If/Else in Rainmeter

Post by JoBu »

you could throw a substitute in there... so something like my WinAmp skin:

Code: Select all

Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=Winamp v1.x
WindowMessage=1024 0 104
MinValue=0
MaxValue=3
IfEqualValue=1
IfEqualAction=!Execute [!RainmeterShowMeter MeterPause][!RainmeterHideMeter MeterPlay]
IfAboveValue=1
IfAboveAction=!Execute [!RainmeterShowMeter MeterPlay][!RainmeterHideMeter MeterPause]
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterShowMeter MeterPlay][!RainmeterHideMeter MeterPause]
Substitute="0":"suspended","1":"engaged","3":"paused"
Hope it helps... if not, I could rig an iTunes code for you... I think.

Btw - I used those subs so that my WinAmp sounded more English. Cuz English rock is awesome.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: If/Else in Rainmeter

Post by jsmorley »

Something like this should work.

[Variables]
ArtistPrefix=""

[MeasureArtistName]
Measure=Plugin
Blah...
Substitute="":"-1"

[MeasureCheckArtist]
Measure=Calc
Formula=[MeasureArtistName]
IfBelowValue=0
IfBelowAction=!RainmeterSetVariable ArtistPrefix ""
IfEqualValue=0
IfEqualAction=!RainmeterSetVariable ArtistPrefix "by "
DynamicVariables=1

[MeterArtist]
Meter=String
MeasureName=MeasureArtistName
Text=#ArtistPrefix#%1
DynamicVariables=1
DonDemon
Posts: 5
Joined: February 21st, 2011, 8:12 pm

Re: If/Else in Rainmeter

Post by DonDemon »

Hmm didn't work, thanks for the help though.
I also tried to simply Substitute="by ":"", but that didn't help either.
Maybe your code doesn't work because it doesn't support iTunes?
DonDemon
Posts: 5
Joined: February 21st, 2011, 8:12 pm

Re: If/Else in Rainmeter

Post by DonDemon »

jsmorley wrote:Something like this should work.

[Variables]
ArtistPrefix=""

[MeasureArtistName]
Measure=Plugin
Blah...
Substitute="":"-1"

[MeasureCheckArtist]
Measure=Calc
Formula=[MeasureArtistName]
IfBelowValue=0
IfBelowAction=!RainmeterSetVariable ArtistPrefix ""
IfEqualValue=0
IfEqualAction=!RainmeterSetVariable ArtistPrefix "by "
DynamicVariables=1

[MeterArtist]
Meter=String
Text=#ArtistPrefix#%1
DynamicVariables=1
Yeah it kind of works, but now I simply get "-1" on my desktop instead of "by".
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: If/Else in Rainmeter

Post by jsmorley »

DonDemon wrote: Yeah it kind of works, but now I simply get "-1" on my desktop instead of "by".
Yeah, give me a sec. I was just looking at it. Probably going to have to move the substitute.
DonDemon
Posts: 5
Joined: February 21st, 2011, 8:12 pm

Re: If/Else in Rainmeter

Post by DonDemon »

I was thinking of putting a Substitute="-1":"" at the bottom of the [MeasureCheckArtist], but that didn't work either.
DonDemon
Posts: 5
Joined: February 21st, 2011, 8:12 pm

Re: If/Else in Rainmeter

Post by DonDemon »

I somewhat fixed it.
What I did was create two separate Measures, like this:

Code: Select all

[measureDataArtist]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtist
Substitute="":"-1"

[measureArtist]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtist
The [MeasureDataArtist] takes care of the "by", and the [MeasureArtist] simply return a value for my Meter. But now I've got a problem that there's no "by" even when a song is playing =/, which makes no sense, actually.

EDIT: nevermind, it works now. I don't know what I did this time, but it works. Thanks. ;)