Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Question on editing coding for this album rating display (Read 741 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Question on editing coding for this album rating display

I am virtually incompetent when it comes to changing these types of things. Basically, I've got my foobar set up to display album ratings from 1-10 via an album rating tag, the display code for which I pieced together a couple of years ago from various user contributions. An album rating of 7/10 would have 7 yellow stars and 3 grey stars:



I've been leaving %album rating% blank for albums I haven't rated but I decided that I prefer to be able to sort in to just my unrated albums via my top left window, which means I need to start using %album rating% = 0. The issue is when I set this it displays red x's instead of ten blank (grey) stars, though it did used to have 10 grey stars if the tag was simply blank:



I'm wondering how I can adjust the code so that it will display ten grey stars for an %album rating% of 0 rather than the x's. Here's the current code:
Code: [Select]
$puts(mychar,$char(9733)$char(8202))

$rgb(245,175,92,225,155,72)

$if(%album rating%,
$ifgreater(%album rating%,0,
$repeat($get(mychar),%album rating%)
$repeat($rgb(230,230,230,210,210,210)$get(mychar),$sub(10,%album rating%))
,
$repeat($rgb(204,13,62,204,13,62)$char(215)'     ',10)$char(215))
,
$repeat($rgb(230,230,230,210,210,210)$get(mychar),10)

)


 

Question on editing coding for this album rating display

Reply #1
The problem with the display appears to be rooted in the script you're using for that view in Album List Panel. Post that script if you want help figuring out what's causing it.

There doesn't appear to be any problem with the script you posted. I tested it in Grouping and as a column and it displayed correctly. I couldn't test it in Album List Panel, obviously, as I would need the entire script.

I'm wondering how I can adjust the code so that it will display ten grey stars for an %album rating% of 0 rather than the x's. Here's the current code:

Code: [Select]
$puts(mychar,$char(9733)$char(8202))

$rgb(245,175,92,225,155,72)

$ifgreater(%album rating%,0,
$repeat($get(mychar),%album rating%)
$repeat($rgb(230,230,230,210,210,210)$get(mychar),$sub(10,%album rating%))
,
$repeat($rgb(230,230,230,210,210,210)$get(mychar),10)
)

That works because a nonexistent tag essentially evaluates to 0. However, there will no longer be any differentiation between unrated albums and albums rated "0". Two different conditions evaluating to 'unrated' might lead to unnecessarily complex scripts. I suggest removing the "0" ratings and allow your unrated albums to be truly unrated. You could use the following script instead:

Code: [Select]
$puts(mychar,$char(9733)$char(8202))

$rgb(245,175,92,225,155,72)

$if(%album rating%,
$repeat($get(mychar),%album rating%)
$repeat($rgb(230,230,230,210,210,210)$get(mychar),$sub(10,%album rating%))
,
$repeat($rgb(230,230,230,210,210,210)$get(mychar),10)
)

As far as the script for Album List Panel is concerned, as a first tier you could simply use:
Code: [Select]
$if2(%album rating%,0)|

And as far as querying for unrated albums in a search is concerned, you can use:
Code: [Select]
%album rating% MISSING