It is currently April 19th, 2024, 6:03 pm

Logical AND && not working

Get help with creating, editing & fixing problems with skins
Teamol
Posts: 1
Joined: March 23rd, 2018, 6:46 am

Logical AND && not working

Post by Teamol »

These IFs are in a measure, while the value UsingPlugin is in [Variables].

Code: Select all

IfCondition=(MeasureUsingPlugin = -1) && (#UsingPlugin# != WebNowPlaying)
IfTrueAction=[!WriteKeyValue "Variables" "UsingPlugin" WebNowPlaying][!Refresh]
IfCondition2=(MeasureUsingPlugin = 1) && (UsingPlugin != NowPlaying)
IfTrueAction2=[!WriteKeyValue "Variables" "UsingPlugin" NowPlaying][[!Refresh]
Rainmeter log says:

Code: Select all

"WebNowPlaying" is unknown: IfCondition=(MeasureUsingPlugin = -1) && (WebNowPlaying != WebNowPlaying) (Muziko\Muziko.ini - [MeasureUsingPlugin])
"UsingPlugin" is unknown: IfCondition2=(MeasureUsingPlugin = 1) && (UsingPlugin != NowPlaying) (Muziko\Muziko.ini - [MeasureUsingPlugin])
Am I using && wrong?
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Logical AND && not working

Post by balala »

The IfConditions are not ok. I suppose by the != symbol you mean not equal, but in Rainmeter this should have to be represented by the <> symbol (unlike in some programming languages, like C, if I'm not wrong). So, replace these option with the following ones:

Code: Select all

IfCondition=(MeasureUsingPlugin = -1) && (#UsingPlugin# <> WebNowPlaying)
...
IfCondition2=(MeasureUsingPlugin = 1) && (UsingPlugin <> NowPlaying)
...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Logical AND && not working

Post by balala »

Sorry I was not careful enough, but there is one more issue: if the UsingPlugin is defined in the [Variables] section (and as such it's a variable), you have to use it not simply as UsingPlugin, but as #UsingPlugin#. This is the syntax of Rainmeter. You used it correctly in the first IfCondition, but didn't in the second one. Fix it: IfCondition2=(MeasureUsingPlugin = 1) && ([color=#FF0000]#[/color]UsingPlugin[color=#FF0000]#[/color] <> NowPlaying).
Also it seems that you don't have a [WebNowPlaying] measure in your code (this is indicated by the first error message). Check your code, to see what have you missed there.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5396
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Logical AND && not working

Post by eclectic-tech »

Teamol wrote:These IFs are in a measure, while the value UsingPlugin is in [Variables].

Code: Select all

IfCondition=(MeasureUsingPlugin = -1) && (#UsingPlugin# != WebNowPlaying)
IfTrueAction=[!WriteKeyValue "Variables" "UsingPlugin" WebNowPlaying][!Refresh]
IfCondition2=(MeasureUsingPlugin = 1) && (UsingPlugin != NowPlaying)
IfTrueAction2=[!WriteKeyValue "Variables" "UsingPlugin" NowPlaying][[!Refresh]
Rainmeter log says:

Code: Select all

"WebNowPlaying" is unknown: IfCondition=(MeasureUsingPlugin = -1) && (WebNowPlaying != WebNowPlaying) (Muziko\Muziko.ini - [MeasureUsingPlugin])
"UsingPlugin" is unknown: IfCondition2=(MeasureUsingPlugin = 1) && (UsingPlugin != NowPlaying) (Muziko\Muziko.ini - [MeasureUsingPlugin])
Am I using && wrong?
The 'unknown' error tells you that 'WebNowPlaying' and 'UsingPlugin' were never defined in the code.

Balala pointed out the problem with the missing hash tags to define UsingPlugin as a #variable#.

You appear to be testing the string value of your current plugin.

Be aware that IfCondition can only be used to evaluate a numeric mathematical formula. No string values may be used in the condition test. See IfMatchActions to test and take action on string values.

To test the string value as either 'WebNowPlaying' or 'NowPlaying', then IfMatch must be used for that, not IfCondition.