INTERACT FORUM

More => Old Versions => JRiver Media Center 26 for Windows => Topic started by: mattkhan on May 10, 2020, 04:19:39 pm

Title: View based on multiple OR conditions
Post by: mattkhan on May 10, 2020, 04:19:39 pm
This should be simple but I don't know how to get the expression language to evaluate to what I want

I want a view which shows results which match either of the following conditions

- Last Played = "never played"
- item is flagged to be rewatched

The former is a built in field
The latter is a custom field which I've added with type = Integer and edit type = Check (i.e. closest approximation of a boolean I could find)

"never played" appears to be a custom rendering of a value of [] . This reads as if it's an empty list but it doesn't seem like any other functions respect this (e.g. isempty, ismissing, listcount)

so basically I want to display where rewatch or not "last played" (assuming a value of 1 evaluates to true and no value evaluates to false)

I have at least 2 problems here

1) what is the default value of a custom field of type integer? it displays as you'd expect as a checkbox but when shown as a plain field, it shows as unset or empty but doesn't respond to ismissing or isempty (or =0)
2) what is the actual value behind "never played"?


Title: Re: View based on multiple OR conditions
Post by: lepa on May 10, 2020, 05:02:32 pm
Doesn't something like this work?
Or(IsEqual([Last played],never played),Compare([Rewatch],=,1),Never played or flagged,Watched)
Title: Re: View based on multiple OR conditions
Post by: RoderickGI on May 10, 2020, 07:46:17 pm
1) what is the default value of a custom field of type integer? it displays as you'd expect as a checkbox but when shown as a plain field, it shows as unset or empty but doesn't respond to ismissing or isempty (or =0)

When such a field is first created it is empty. You can view the raw contents of the field by writing the field as [Rewatch,0].

When you Check the field it is set to 1. When you then uncheck the field it is set to 0. I use such checkbox fields for TV program management, and just test for the field being equal to 1. Depending on the application, it has been recommended to set the field to 0 on import, using Tag on Import, but I haven't found that necessary.



2) what is the actual value behind "never played"?

It is empty. You can view the raw contents of the field by writing the field as [Last Played,0]. When you edit this tag, the only option is to delete an existing value. The Edit Type is "Cealr Only". So IsEmpty(...) will operate on it correctly, using the form IsEmpty([Last Played,0]), and will produce a 0 or 1 result.

So, Lepa's expression could be written differently using the above information;

Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1),Never played or flagged,Watched)



But Lepa's expression doesn't output "Never played or flagged" or "Watched", just 0 or 1.

I went looking for the description in the Expression functions [HELP WANTED] (https://yabb.jriver.com/interact/index.php/topic,124543.0.html) thread and couldn't find it, even though I know it used to be in there. The Release Notes say:
NEW: Added the expression function Or(...) to test a list of values and output true if any are set.

EDIT: Found it, but no more information there. https://yabb.jriver.com/interact/index.php/topic,125140.msg866670.html#msg866670

So I guess the Or(...) function does just output 0 or 1, so the expression needs an If(...) function:

If(Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1)),Never played or flagged,Watched)

Which works to display "Never played or flagged" or "Watched".



Or if you want to use it in a View or Smartlist definition, in "Set Rules for Display"

[=If(Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1)))]=1

But there are probably simpler expressions that could be used. I just wanted to play with the Or(...) function.  :D

Oh yeah, don't need that If(...) any more;
[=Or(Compare([Last played,0],=,0),Compare([Rewatch],=,1))]=1
Title: Re: View based on multiple OR conditions
Post by: mattkhan on May 11, 2020, 10:44:11 am
Thanks, v helpful

I've never got on with excel style query languages, not sure I ever will :) An embedded script engine using some common language that could query the library would be an interesting option.