Thanks, that works. I find it strange, however, that "1234 LESS 2147483648" isn't just evaluated normally and logically. Isn't that basically an fb2k bug? And why, then, advertise $rand() at all; what's it ever good for in query strings?
Anyways; what I really want to use $rand() for is to play differently rated tracks with different probabilities. I've come up with this solution:
$if($not(
// Only play the following.
$and(
$not($meta_test(duplicate)),
$or(
// Play unrated.
$not($meta_test(rating)),
// (Don't play anything rated lower than 3.)
$and(
// Play rating 3 with 50% probability.
$ifequal(%rating%,3,$not($not()),0),
$greater($muldiv(4294967295,50,100),$rand())
),
$and(
// Play rating 4 with 90% probability.
$ifequal(%rating%,4,$not($not()),0),
$greater($muldiv(4294967295,90,100),$rand())
),
$and(
// Play rating 5 with 95% probability.
$ifequal(%rating%,5,$not($not()),0),
$greater($muldiv(4294967295,95,100),$rand())
)
)
)
),1,0)
(BTW: $not($not()) is currently necessary to get boolean true for $and().)
This brings me to the following improvement suggestions for foo_skip:
- The title formatting documentation says: "Each function becomes a string or number, and/or a truth value (not output)". Is it possible to also support outer truth values, so we can have functions like $not(), $and() or $greater() on the outermost level without the necessity of wrapping it in $if(...,1,0)? If it's not possible by API, the component could perhaps do the wrapping itself.
- Please support negating the query with a checkbox, meaning: Only play tracks that match the following query.
- I must develop my query in an external editor, replace the regex "\s" with "" for every iteration of it and store it in a text file I need to keep separately. My above query confusingly becomes: "$if($not($and($not($meta_test(duplicate)),$or($not($meta_test(rating)),$and($ifequal(%rating%,3,$not($not()),0),$greater($muldiv(4294967295,50,100),$rand())),$and($ifequal(%rating%,4,$not($not()),0),$greater($muldiv(4294967295,90,100),$rand())),$and($ifequal(%rating%,5,$not($not()),0),$greater($muldiv(4294967295,95,100),$rand())),))),1,0)". According to the documentation, title formatting strings support comments with //, which is great. If indentation whitespaces make problems, just remove them when building the internal query that's applied. Indenting in the textbox would ideally be easy by pressing tab without going to the next GUI element. And is a monospace font possible like in fb2k's info window?
- Query strings should be better managable. Currently, there's just a history. But that can make it hard to distinguish between productive strings that you want to go back to and past iterations of those strings that weren't perfect yet. You should be able to name multiple query strings and choose between them. Ideally, there would be a widget like the "Order" drop-down box ("Default" vs. "Repeat" vs. "Shuffle") that contains the defined names, so that one can easily change the skip mode (e.g., "The better the more probable" vs. "Just unrated" to catch up on rating those). The text of the label before the drop-down box should perhaps be freely defineable, because just something like "Skip" wouldn't cut it when the negating checkbox is used. Certain options like "Treat query as titleformat string" and the new negating checkbox would need to be tied to a named query.