Skip to main content

Topic: $if statement in Media Library/Album List/View (Read 961 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • ultrared
  • [*]
$if statement in Media Library/Album List/View
I'm trying to set up some views, however $if statements are either not working or I've missed something in the documentation...

Ultimately, I want to create views for 'recently added' as well as 'new unsorted' etc., but here's a simple example of the issue I'm having:

Adding a new view with this script:

$if(%genre% HAS "Rock",%album artist%,)

..i would expect it to return all album artists which contain tagged mp3s with a genre containing Rock

However it returns all album artists which have any genre, ie. the same results as

$if(%genre%,%album artist%,)

I've tried different (needlessly complicated) approaches, but to no avail. Also tried different simple examples, all seem to do the same thing. Whenever there's a HAS or IS or whatever, it ignores it and just returns 'true' for the %variable% in the statement if on its own it would be 'true'.


What am I missing?


PS. Apologies if this is the wrong forum - Tech Support is not about 'How To' and General isn't about 'Tech Support'... Please move my post if needed.


  • foosion
  • [*][*][*][*][*]
  • Moderator
$if statement in Media Library/Album List/View
Reply #1
Queries are not supported in title formatting expressions. As far as the the $if function is concerned, $if(%genre% HAS "Rock",...), $if(blah%genre%meh,...) and $if(%genre%,...) are all the same. If you want to achieve the equivalent of the %genre$ HAS Rock query inside title formatting, you have to use $if($strstr(%genre%,Rock),%album artist%).
http://foosion.foobar2000.org/ - my components for foobar2000

  • ultrared
  • [*]
$if statement in Media Library/Album List/View
Reply #2
Thank you for the quick answer.. I didn't see that in the documentation anywhere

$if($strstr(%genre%,Rock),%album artist%) works.

This is going to leave me with a headache though, for something like this (a recently added view):

$if(%last_modified% DURING LAST 2 WEEKS,%album artist%)

Yes, I know that won't work - but, you can see what I want it to do.


  • db1989
  • [*][*][*][*][*]
  • Global Moderator
$if statement in Media Library/Album List/View
Reply #3
I didn't see that in the documentation anywhere
http://wiki.hydrogenaudio.org/index.php?ti...tting_Reference
A copy of which is included with the installer, alongside the document on query syntax. Both make it clear which separate contexts they function in.

Quote
Ultimately, I want to create views for 'recently added' as well as 'new unsorted' etc.
This is why autoplaylists exist. They are constructed from query syntax. An example tutorial on how to use them: http://nujufoobar.blogspot.co.uk/2013/01/h...from-media.html

P.S. Yes, General is the correct forum for questions that can be answered by other users. Support is for problems/unintended behaviour that require attention from developers.
  • Last Edit: 28 July, 2013, 04:06:18 PM by db1989

  • ultrared
  • [*]
$if statement in Media Library/Album List/View
Reply #4
Thanks