INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: [24.0.75; Query] JRiver Expression Language and indentation  (Read 1113 times)

Goatshade

  • Citizen of the Universe
  • *****
  • Posts: 651
[24.0.75; Query] JRiver Expression Language and indentation
« 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
,
)
)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41956
  • Shoes gone again!
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #1 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.
Logged
Matt Ashland, JRiver Media Center

Goatshade

  • Citizen of the Universe
  • *****
  • Posts: 651
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #2 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.
Logged

biblio

  • Junior Woodchuck
  • **
  • Posts: 81
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #3 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.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41956
  • Shoes gone again!
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #4 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?
Logged
Matt Ashland, JRiver Media Center

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #5 on: March 04, 2019, 07:29:50 pm »

As I have mentioned before, I use Notepad++ is pretty good for writing code for MC. It has a user-created language module for MC, 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.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

biblio

  • Junior Woodchuck
  • **
  • Posts: 81
Re: [24.0.75; Query] JRiver Expression Language and indentation
« Reply #6 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.
Logged
Pages: [1]   Go Up