INTERACT FORUM

More => Old Versions => JRiver Media Center 24 for Windows => Topic started by: Goatshade on March 04, 2019, 04:21:29 pm

Title: [24.0.75; Query] JRiver Expression Language and indentation
Post by: Goatshade on March 04, 2019, 04:21:29 pm
Does the expression language properly allow for indentation á la Python? I've run in to a number of issues when formatting expressions this way so far. First, for thumbnail text at album level, I had the following code:
Code: [Select]
ListBuild(
0
,
/#
#/
,
RatingStars() [Rating]
,
[Name]
,
[Custom 2]
)
Unfortunately, this results in several unintended and unwanted line breaks in the output. The only way to get it to display correctly is to do this:
Code: [Select]
ListBuild(
0
,
/#
#/,
RatingStars() [Rating],[Name],[Custom 2]
)
As another example, the calculated data as entered in [Custom 1], which appears in [Custom 2]* and governs which dates are displayed at album level, is as follows:
Code: [Select]
If(
IsEqual(
[Notes]
,
Compilation
,
7
)
,
[Date (release),0]
,
[Date,0]
)
As it is written, albums are sorted according to [Date (release)], even when "Compilation" does not appear at all in [Notes]. The only way I've managed to fix it thus far is to remove all line breaks entirely and relegate the code to one line—something from which I am trying to get away after years of struggling to manage larger, denser strings.

What's going on, here?

* For reference, this is [Custom 2]:
Code: [Select]
If(
!IsEmpty(
[Date (override)]
,
0
)
,
FormatDate(
[Date (override),0]
,
%x
,
)
,
FormatDate(
[Custom 1]
,
%x
,
)
)
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: Matt on March 04, 2019, 04:40:40 pm
I don't think you can add line breaks just to try to make the code prettier.

They're going to get interpreted as literal strings in some cases.

That's why the only working solution you found was to remove all the line breaks.  Not sure if there's a way around this.
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: Goatshade on March 04, 2019, 04:45:36 pm
I see.

Would it be possible to implement indentation and line break respect, possibly as a toggle?

Seriously: These examples are relatively tame, but I've written strings that are much longer. At a certain point, having no line breaks or indents becomes... less than feasible.
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: biblio on March 04, 2019, 05:16:57 pm
Visually when writing code that needs to be condensed I find it better to have a scratchpad where you write then paste into another file when you take out the extra characters.

I don't know which note editor in windows works easily but in linux i do this and replace all the 4 spaces "    " with nothing then new lines "\n" with a space as i indent in 4's.

This is also how i write excel formulas as its better to lay it out first before pasting into excel.
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: Matt on March 04, 2019, 07:22:13 pm
I was thinking about eating newlines and tabs around commas but I'm afraid of breaking expressions that need the newlines.  Thoughts?
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: RoderickGI on March 04, 2019, 07:29:50 pm
As I have mentioned before (https://yabb.jriver.com/interact/index.php/topic,117974.msg816572.html#msg816572), I use Notepad++ is pretty good for writing code for MC. It has a user-created language module for MC (https://yabb.jriver.com/interact/index.php/topic,108016.msg749233.html#msg749233), but it isn't perfect, constantly getting bracketing wrong because MC includes open and close brackets inside field names.

But I'm sure that language module could be improved to make it work properly. I think it just needs more MC commands and field names defined in the module. But I haven't taken a look and probably won't.

Matt, maybe some help in defining the Notepad++ MC Language would be a better solution. Maybe even allow expressions to be edited with an external editor, in this case Notepad++, with an edit button wherever required to launch Notepad++ and open a file with the expression in it, or start a new file. JRiver could host the most up to date language module for Notepad++, so that everyone could find it easily.

Just a thought.
Title: Re: [24.0.75; Query] JRiver Expression Language and indentation
Post by: biblio on March 04, 2019, 09:07:59 pm
I was thinking about eating newlines and tabs around commas but I'm afraid of breaking expressions that need the newlines.  Thoughts?

I wouldn't think there is benefit in change.