INTERACT FORUM

Please login or register.

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

Author Topic: Expression Language Wiki  (Read 10690 times)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #50 on: June 08, 2020, 08:54:10 am »

Yes, you're right. That should be a fwd-slash, not a backslash, but it's really not needed as you mention. I keep thinking that it's the backslash that needs escaping...
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Language Wiki
« Reply #51 on: June 10, 2020, 12:49:40 am »

Guys, please let me know if you see any new functions that are missing from the Syntax Highlighter.

I've noted ListRemove (which was recently added) needs to be included.

Marko, when you get back to Regex(), I noticed the "additional information" link is out of date.

Thanks!
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #52 on: June 10, 2020, 01:12:13 am »

Sorry, I did say I would let you know when I found any. My bad.

Both Marko and I are adding any new functions we come across, or changes required, to our first posts in this thread. So that is a good summary of any new functions.
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

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #53 on: June 14, 2020, 03:07:57 am »

Marko, if I may, a little feedback/info on the Regex-2 documentation...

First, it's important to note somewhere that MC's Regex() function takes a non-standard regular expression syntax, in that it will ONLY return results for things that are explicitly placed in a capture group.

<snip>

-Will

What is used now Hendrik?

The Wiki is out of date. It is probably important that people know what version of Regex is used.
https://wiki.jriver.com/index.php/String_Manipulation_Functions#Regex.28.E2.80.A6.29
https://wiki.jriver.com/index.php/Regular_expression_syntax

I'll update the Wiki, if I know what to say in it.

Morning all, Will, thanks for the additional Regex() information. That's the two links above updated, kind of blindly, with the information provided. Both OK?

Char() has also been added, although, I'm still struggling to understand when you would use this function, rather than just enter the character directly?

-marko

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Language Wiki
« Reply #54 on: June 14, 2020, 12:26:59 pm »

Marko,

The Regex info looks good to me. I'd suggest two small changes...

This first sentence of paragraph 2 is wrong. I would change "All match captures are placed into special variables" to "Up to 9 match captures, one for each capture group, are placed into special variables".

I would also move the sentence mentioning the engine to the additional information link, since it only mentions old versions and is years out of date.

Thank you for going to the trouble of updating the page. I think it will help people.

-Will
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #55 on: June 15, 2020, 12:00:02 am »

Sorted. Thanks for the information to put there :)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #56 on: June 21, 2020, 05:13:11 am »

The wiki for Math(Rand()) is wrong - It says:
rand(x)   Returns a random value ranging between 0 to x.

But actually it needs 2 params:
rand(x,y)   Returns a random value between x and y
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #57 on: June 21, 2020, 06:39:08 am »

Sorted. Also added it to the misc. expressions section.

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #58 on: June 21, 2020, 09:37:49 am »

What do you mean by "added to the misc section" ? I don't see it there - and it shouldn't be there, it's a Math subfunction.

It looks like you removed the randn() function. Actually both of them exist:
rand(x,y)   Returns a random value ranging between x and y.
randn(x)   Returns a random value ranging between -x and x.

PS: Ah, got it, Rand() works both inside and outside of Math. But RandN() only works inside of Math(). You added Rand() description to the Misc section, but not to the index of the main EL page.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #59 on: June 21, 2020, 10:24:17 am »

Told you I wasn't firing on all cylinders today!

Should be all sorted now. Thanks for checking.

Slowly getting through the todo list, more done now than still to do.

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #60 on: July 04, 2020, 02:34:35 am »

Morning all,

I could not get Translate() to do anything for me at all, other than return whatever string it had been given, literally.
My MC language is set to "English (British)"

Translate(String) returns String
Translat(chaîne) returns chaîne

I set my language to Albanian, and the above examples resulted in the same, so I quickly returned my language setting to English :D

Any ideas?

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #61 on: July 04, 2020, 04:30:58 am »

Same with URLify(), not sure what it's suppose to do. Hexify() works.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #62 on: July 04, 2020, 10:53:57 pm »

I went through all you have done so far Marko, and made a few little changes.

1. Edited punctuation of the And(...) and Or(...) examples for better readability. Just made the last output example its own sentence.

2. Added Row(...) to Function Index, as it was missing.
Note: There appears to be something strange going on with the indexing of the Row(...) function in the Wiki, and I can't work it out. I check a function by searching for it in the Wiki, and that is supposed to result in three "primary" results, if you like. Results I am looking for are:
a. The redirect.
b. The Expression Language page.
c. The link to the Expression Language sub-page, which in the case of Row(...) would be the "Miscellaneous Functions" page.
For the Row(...) function c. above doesn't show up, whether I search for "Row(", Row(...), or the summary description, ": Returns the row number of a list entry".
For comparison, searching the Wiki for StackCount(...) clearly shows the three pages.

The only difference I could see was the page didn't include the <nowiki> function, so I added it as per below.
'''{{monospace|Row()}}'''
'''{{monospace|<nowiki>Row()</nowiki>}}'''
That still didn't fix the search issue. I guess it doesn't matter, as the redirect works, and the search finds that and the Expression Language page.

3. I edited the Range(...) function examples to remove the spaces after the semi-colons in the Returns values, since MC no longer adds those spaces.

4. I added some examples for modes 9 to 15 for IsEqual to highlight both List search functions and ANY and ALL search functions. Mainly because I wanted to test these.

Let me know if I got anything wrong!  8)
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

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #63 on: July 04, 2020, 11:00:04 pm »

I can't find any information on Translate(...) or get it to do anything either.

I suspect HEXify replaced URLify, since HEXify just seems to convert spaces to %20, just as URLify generally does for other languages. Maybe it was a rename. I do remember some discussion on URLify, I think with Matt, but I can't find it now. The function has been around a long time.
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

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #64 on: July 05, 2020, 01:42:40 am »

Cheers Rod, I have also been correcting little things I spot as I've going around these, and also alphabetising (sp?) the function groups where I can.
Range() was yours ;)

Matt has confirmed that the error in StackCount and the tooltip for Remote Articles will be sorted next build.

Seems we may have to wait some time for more info regarding the Playlists database, so I'll just go ahead and and get DbLocation() added and edit it up once we have a better understanding.

I reckon ListLimit() could be tidied up and fleshed out a bit too.

We're almost there...

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #65 on: July 05, 2020, 02:51:54 am »

I did a bit of alphabetising some time back, if I recall correctly.

Range() was yours ;)

So it was! I guess whitespace trimming hadn't sunk into my mind when I wrote that.  ;D

I might find time to write something about my understanding of the Playlist Database in your other thread.

I reckon ListLimit() could be tidied up and fleshed out a bit too.

I'll have a look at that if you like. I haven't done much so far really, but I ma checking bits and pieces as I work on other stuff. This is not an easy or quick task unless you are doing it often, which I'm not.
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

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #66 on: July 05, 2020, 04:03:20 am »

I might find time to write something about my understanding of the Playlist Database in your other thread.
Anything that might stimulate a corroborative response :)
I was thinking it might have something to do with handheld syncing, and maybe iTunes importing....

I'll have a look at that if you like. I haven't done much so far really, but I ma checking bits and pieces as I work on other stuff. This is not an easy or quick task unless you are doing it often, which I'm not.
For sure, go for it.

I've kind of ran into a brick wall near the end of this...
As far as I can tell:
  • Translate(...) and URLify(...) don't do anything
  • Literal(...) seems, well, pointless? The only thing I seem to be able to get it to do is convert a field like, say, duration, from an integer to a string value. Where would this function be useful?
  • RatingStars10(...) is broken, as in, also not doing anything.


-marko

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #67 on: July 05, 2020, 06:27:59 am »

There's an undocumented function called itemcount() - seems to always return the number of files in the library. Not sure if takes arguments, I tried with different values and filter expressions.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #68 on: July 05, 2020, 06:49:09 am »

There's an undocumented function called itemcount() - seems to always return the number of files in the library. Not sure if takes arguments, I tried with different values and filter expressions.

I just added that to my list on Reply #3 in this thread. There is a link to a thread discussing it, and there was an earlier thread I believe.
The ToolTip for ItemCount() is correct as well.


  • Literal(...) seems, well, pointless? The only thing I seem to be able to get it to do is convert a field like, say, duration, from an integer to a string value. Where would this function be useful?
I have a vague recollection of a discussion about a literal string output from an expression was required to some further processing. I have searched but can't find a reference.

  • RatingStars10(...) is broken, as in, also not doing anything.
Used for display only. can be used in the top Display area of Standard View, or in columns in Views. See image with example.
https://yabb.jriver.com/interact/index.php/topic,117422.0.html
20.0.123 (6/29/2015)
14. NEW: Added the RatingStars10(...) expression function to show a 10 star rating field (it takes the field name as a parameter).
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

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #69 on: July 05, 2020, 07:05:46 am »

Oh for goodness sake, I'm going to open a beer and watch the F1....

I've been using RatingStars10([Track #])

Still cursing :D

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #70 on: July 05, 2020, 07:12:08 am »

 ;D ;D ;D

Here is another facepalm for you.

DBLocation() seems to return the same information as FileDBLocation().

... Including calling the "Removed" database "Was Removed".
... Wait, I've also found reference to the "Removed" database. So there is a "Removed" and "Was Removed" database. I didn't know that.
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

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #71 on: July 05, 2020, 07:23:44 am »

Thanks Roderick, good info.

So RatingStars10(IMDb Rating) works for me, and ItemCount(/[Genre/]) also works (returns number of files with same genre as current file).

The language is very inconsistent, this highlights one case of that: ItemCount takes an escaped field name, but RatingStars10 takes an un-escaped one. I understand that ItemCount is supposed to take a full expression, hence the escaping - but from my tests things like ItemCount(/[genre/]="War") don't work as expected, it always returns the same value as just itemcount(/[genre/]).

Also kind of counter-intuitive that any invalid expression returns the total item count in the library instead of zero (though I understand why it does so).
 
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #72 on: July 05, 2020, 07:31:05 am »

It does indeed, almost, though, both of mine only use "Removed". I looked at these during the week, and wondered about the redundancy of plain dblocation...

I set two panes side by side, using dblocation()&datatype=[ list] and filedblocation()&datatype=[ list]

Both are identical. The only difference I could find is that dblocation doesn't take a parameter. Change the filedblocation()&datatype=[ list] to filedblocation(1)&datatype=[ list] and you get the "bit position" thing, which I can't follow, going on instead. If you have bi-directional filtering on, selecting these bit position numbers are mildly interest for a few minutes.

I had a ton of stuff with no [File Name] data in the "Other (4096)" database... Couldn't handle that so removed them all... It's like MC Feng-Shui :)

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Expression Language Wiki
« Reply #73 on: July 05, 2020, 07:35:11 am »

Thanks for the help!
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #74 on: July 05, 2020, 07:53:14 am »

It does indeed, almost, though, both of mine only use "Removed".

If you create a new blank View that doesn't inherit any criteria from its parent, and set the Databases Limited to All (~d=a) rather than leaving no limitation on it, and then filter that View using "[=dblocation()]=Was" (no quotes), do you have any files in the "Was Removed" database then? I seem to have a lot of TV SHow Series and Season Cover Art images in that database, and quite a few Album Cover Art images. Possibly those images have been removed at some time, and then reinstated. This is in my test Library, which gets hacked round quite a lot.

I had a ton of stuff with no [File Name] data in the "Other (4096)" database... Couldn't handle that so removed them all... It's like MC Feng-Shui :)

I like that.  8)

Enough for me now. Bedtime. I still didn't look at ListLimit!  :P
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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression Language Wiki
« Reply #75 on: July 05, 2020, 10:44:10 am »

Literal() was my request:
https://yabb.jriver.com/interact/index.php/topic,122149.msg845247.html#msg845247

I suspect the normally-named expression function was added so that the /* ... /* special formatting could be added? Though I'm guessing on that...
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #76 on: July 05, 2020, 06:17:42 pm »

G'Day Glynor.
Thanks for the hint. I saw that but didn't really connect the two things. Maybe that was the source though.

So we have:
Literal()  Outputs the enclosed text exactly as it is.
/*     /*  Outputs the enclosed text exactly as it is.
/#    #/  Escapes everything inside this formatting.

If(IsEqual([Artist], Queen, 1), Literal(If all music was Queen, I would be 10/10ths happy!), Literal(This is not Queen, which makes me sad. :-/))

But that doesn't work, with the sad face breaking the expression completely and generating an error. That can be fixed by removing the sad face, putting a space after the sad face (so that the space is escaped instead of the bracket... incorrectly), or changing the sad face to :-\.

If(IsEqual([Artist], Queen, 1), Literal(If all music was Queen, I would be 10/10ths happy!), Literal(This is not Queen, which makes me sad. :-/ ))

But the output is still broken then, with the text truncated at the comma after the word Queen. So MC isn't handling what is inside the Literal() expression as just text, but is processing it, although incorrectly given the implied extra parameters in the If function. Where the [Artist] is Queen, I get an output of "If all music was Queen". When the [Artist] isn't Queen, I get "This is not Queen". So MC knows where to get the output value from, but trips over the comma in each value when it tries to output it. But also trips over the / in the sad face, using it to escape the bracket following it.


This expression works correctly though, even without the space after the sad face.
If(IsEqual([Artist], Queen, 1), /*If all music was Queen, I would be 10/10ths happy!/*, /*This is not Queen, which makes me sad. :-//*)


So Literal() and /* ... /* aren't equivalent. Or Literal() is broken.



Also note that escaping the text works correctly as well, even without the space after the sad face.
If(IsEqual([Artist], Queen, 1), /#If all music was Queen, I would be 10/10ths happy!#/, /#This is not Queen, which makes me sad. :-/#/)

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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression Language Wiki
« Reply #77 on: July 05, 2020, 07:26:46 pm »

/#    #/  Escapes everything inside this formatting.

That is the new comment functionality, not escaping everything, if I'm not mistaken.

I'm assuming the Literal() function is used internally, and isn't really designed to be used by the user, but I could be wrong on ALL of this. We probably need Matt or Hendrik to explain.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #78 on: July 05, 2020, 08:02:32 pm »

That is the new comment functionality, not escaping everything, if I'm not mistaken.

Nope, that escapes everything inside, as documented in the Expression Language Wiki, under "Expression Language Syntax". You probably wrote that... Ah no, it was MrC in "Revision as of 14:17, 26 August 2013".

/# ... #/ has been used extensively in Regex to escape the whole Regex Expression for passing to the Regex function, instead of escaping individual characters. That is documented in the Wiki.

/* ... /* is the Comment "Literal" functionality.
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

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #79 on: July 06, 2020, 07:34:29 am »

/* ... /* is the Comment functionality.

Well, not "comment" as it still produces an output. "Literal" is more accurate, as in, a literal block of text which is not parsed as an expression.

Language inconsistency: why is this one /* /* instead of /* */, like /# #/...
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #80 on: July 06, 2020, 06:01:28 pm »

Correct. Post fixed. My mistake.

Also, in the Resource.xml file, <!-- Comments in here --> is used for comments.

It's because MC has grown organically, and isn't documented in detail I suspect.
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

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10935
Re: Expression Language Wiki
« Reply #81 on: July 06, 2020, 06:03:57 pm »

Also, in the Resource.xml file, <!-- Comments in here --> is used for comments.

Thats a given, since its XML. Not our invention! :)
Logged
~ nevcairiel
~ Author of LAV Filters

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #82 on: July 06, 2020, 07:39:55 pm »

Thats a given, since its XML. Not our invention! :)

 ;D ;D  I can forgive you for that.

I was thinking maybe that if the MC Expression language was to actually have true Comments, and not literals as the existing syntax appears to be, it might use a standard like XML. Or maybe whatever C, C#, or C++ uses.
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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression Language Wiki
« Reply #83 on: July 06, 2020, 10:13:59 pm »

Yeah. I was mixed up. There was a thread recently where adding a "true comment" notation was discussed and I'd thought it actually did get added, and that this was it. Obviously I was wrong about the latter, and possibly wrong that it even actually got added at all.

I do remember a thread recently though. What makes it stand out is that someone had a very clever solution in the thread about using a custom field to replicate comments (by simply naming your field cleverly and then adding the comment as an "argument" to the field, which will then get dropped and ignored).

But, I don't remember the details and I'm too lazy to look it up right now.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #84 on: July 07, 2020, 03:07:24 am »

https://yabb.jriver.com/interact/index.php/topic,124543.msg871690.html#msg871690

Doof had the idea of calling the field simply "/" so it becomes [//, this is a comment]
I added that as a syntax highlight item to Zelda as a sort of unofficial commenting system.

I also like "Alexa"... [Alexa, this code needs improvement!]
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #85 on: July 12, 2020, 12:57:03 pm »

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Language Wiki
« Reply #86 on: July 12, 2020, 03:08:26 pm »

Is this all correct?
https://wiki.jriver.com/index.php/Grouping_Functions#GroupCountQuery

Well, I don't think the initial summary "Counts the number of items in a specified group" conveys the functionality correctly.

I also think it would be beneficial to add another simpler example, as all the escapes in your examples make it a bit hard to follow for the inexperienced.

It's also helpful to contrast GroupCountQuery with GroupCount.

From my original definition:

GroupCountQuery(field1, field2) counts a given field2 not for members of the current context, but for files that share a field1 with the current context.

This could be perhaps better restated as: GroupCountQuery(field1, field2) counts the number of different field2 entries for files that share a field1 with the current file.

So for example, if you're looking at an individual track in the AC/DC album Back in Black, then:

GroupCount(Track #) returns 1 because there is only 1 track # value in the context.  Likewise GroupCount(Name) would also return 1.

GroupCountQuery(Album, Track #) would give you the count of all tracks in the Back in Black album.
GroupCountQuery(Album, Name) would give you the count of all Names in the Back in Black album, probably the same result.

GroupCountQuery(Artist, Album) would give you the count of Albums by AC/DC.

Field1 can be used to specify multiple shared criteria:
GroupCountQuery(Artist;Producer, Album) would give you the count of all AC/DC albums with the same producer as the current album.

Performing GroupCountQuery(Artist, Album) would report the exact same result if you were looking at ANY AC/DC track, because they all share the same Artist.

A note about theater view is also helpful:
Because when you are looking at file details in Theater View you are always looking at a single file, GroupCountQuery and GroupSummaryQuery are the only ways to incorporate information about related files in your display.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #87 on: July 19, 2020, 06:48:38 am »

Thanks wer. Not fully grasping what these were doing, and not having your concept post bookmarked, I transcribed from the function tooltips  ::)

Well, I don't think the initial summary "Counts the number of items in a specified group" conveys the functionality correctly.
Better now?

I also think it would be beneficial to add another simpler example, as all the escapes in your examples make it a bit hard to follow for the inexperienced.
Still todo.

It's also helpful to contrast GroupCountQuery with GroupCount.
I've added GroupSummaryQuery() today, and drawn attention to the difference in Example #1. As above, tweaking of GroupCountQuery() is still on the todo list. I feel my understanding is better today than it was last week, but could you give GroupSummaryQuery() a quick once-over before I revisit GroupCountQuery()? Cheers.

A note about theater view is also helpful:
Because when you are looking at file details in Theater View you are always looking at a single file, GroupCountQuery and GroupSummaryQuery are the only ways to incorporate information about related files in your display.
I've added a paragraph to the "Preview" introduction at the top of the page referencing the usefulness of these two functions, specifically, in Theater View. This is about the time I discovered, that, as far as I could tell, there is nothing in the wiki covering the oh-so-powerful Theater View File Info Panel apart from a nod to its existence at the bottom of a TV Episodes page.

@RoderickGI...
We also need to add to the list:
NEW: String literals can be defined in expressions by using /* comment here /*.  The text will be output without any formatting. https://yabb.jriver.com/interact/index.php?topic=122149.0
Done. (Added info to Expression Language Syntax intro on the main Expressions page.)

ItemCount(...) https://yabb.jriver.com/interact/index.php?topic=122319.0
Sorted.

Should add a link to Boolean Operations as they would be helpful, but not easy to find.
I wasn't sure about this. The examples on that page were not immediately clear to me, and I didn't have time to spend on them, but, we do now have both And() and Or() functions... Are these the same as referenced on that page? If yes, that just leaves XOR, and I have no idea what that means, and a very quick Google only made things even less clear!! :D

We should reference functions that are available in the Player Display such as [Remaining Time], [Playlist Remaining Time] etc., which look like fields but aren't. See https://yabb.jriver.com/interact/index.php/topic,125595.0.html and search for more. Maybe these are already in the Wiki somewhere... Maybe not. This is all a quick search finds: https://wiki.jriver.com/index.php/Player
We should. I need a break though :)
On top of this, there is, I feel, a very real need to have pages dedicated to both the new Tag Window, and the Theater View File Info Panel as they are both brilliant and powerful tools that make the interface presented to the user highly customisable, but, especially in the case of Theater View, not immediately obvious to the user, how much power they have at their disposal via these two tools.

=============
So, today, I believe we finally have all existing functions present in the Functions Index, and that's only taken eight or nine weeks, which, all things considered, is not too bad really. Thanks to all that helped along the way. There are just a few things left on the todo list which will hopefully be boxed off next weekend.

-marko

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72438
  • Where did I put my teeth?
Re: Expression Language Wiki
« Reply #88 on: July 19, 2020, 07:48:53 am »

Thanks, Marko.  And wer.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #89 on: July 21, 2020, 04:58:28 am »

I wasn't sure about this. The examples on that page were not immediately clear to me, and I didn't have time to spend on them, but, we do now have both And() and Or() functions... Are these the same as referenced on that page? If yes, that just leaves XOR, and I have no idea what that means, and a very quick Google only made things even less clear!! :D

And(A,B) - true if both A and B are true; for more elements, true if ALL elements are true
Or(A,B) - true if A is true, or B is true, or both are true; for more elements, true if AT LEAST one element is true
Xor(A,B) - Exclusive OR; true if ONLY A is true or ONLY B is true; for more elements, true if JUST one element is true an odd number of elements are true

True is defined as "1", False is "0". A and B are values or expressions that evaluate to some value. Bool expressions in MC (such as if()/isEqual()/ListContains()/etc) always return "0" or "1".

However, there are some inconsistencies in MC implementation of AND and OR (XOR is not implemented AFAIK). The results are NOT exactly the same as if we just used the "equivalent" Math() expressions mentioned in that page - And() and Or() are more flexible than Math().
MC seems to parse the arguments as numbers, and considers TRUE to be any non-zero value (FALSE is just zero). Examples:

0 = FALSE
1 = TRUE
-1 = TRUE (valid number, non-zero)
blank/empty string = FALSE (as the default argument value is then "0")
9.99 = TRUE (valid number 9; decimals are probably ignored)
0.99 = FALSE (decimals are ignored, so this is a zero)
.99 = FALSE (either parsed as zero or as blank, which is also zero)
apple = FALSE (not a number - note that in some languages this would be TRUE as it's a non-zero/non-null value)
apple123 = FALSE (not a number)
123apple = TRUE (it parses the 123 and ignores the rest)
9.99apple = TRUE (valid number 9, non zero)
-7.5apple = TRUE (still a valid number -7, non-zero)

You may want to document the behaviour.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #90 on: July 25, 2020, 02:48:19 am »

For me, we're all done. Happy days.

Without question, there are gaps in some of the older entries, and pages that need to be created to explain in more detail some other referenced item or subject, such as the Theater View File Info Panel, but I feel that once you start down that road, it would become a never-ending journey akin to trying to read the entire internet, so for now, I'm done.

zybex,
I've read your entire "And/Or" reply three or four times, and it's just not joining up in my old head. The whole "1" or "0" thing, I get, whilst this, "apple = FALSE (not a number - note that in some languages this would be TRUE as it's a non-zero/non-null value)" leaves me cold :)

This could be due to the fact that, as I learn, I create useable examples either in my head or in MC, and for some reason, that sticks, and then, when I need to do something, the function I need is just "there". With this stuff, it's just not happening for me.

What will happen though, is if I try using the And() or the Or() functions in the future, and results are not what I expect, I will remember your post above which I've bookmarked, and then, it might start to fall into place.

Right now, I couldn't begin to document something I have such a loose grasp over. Others could also make additions to the wiki mind you, I think you just need to sign up and then request editing rights.

-marko

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #91 on: July 25, 2020, 04:10:42 pm »

Well done Marko. What a great effort. Mine has been trivial compared to yours.

I still have some things to do, not forgotten, but not at the top of my todo list either.
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

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #92 on: September 07, 2020, 04:08:35 am »

I've just tested and it seems that Matt did add the ListMath() function listed here:
https://yabb.jriver.com/interact/index.php/topic,124543.msg877813.html#msg877813

It doesn't show up in the release notes.

Other needed edits:
- add the min/max/sum/avg functions (Miscellaneous? I feel the categories should also be reviewed)
- remove min/max from the Math() section as these are now generic functions
- same for Rand(), it's now a generic function (but randN is still a math subfunction)
- delimit([Date (year)], {, }) => example produces }2012{ instead of {2012}; the brackets are missing in the example output
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: Expression Language Wiki
« Reply #93 on: September 07, 2020, 05:30:49 am »

The red list in my tracker started growing again! https://yabb.jriver.com/interact/index.php/topic,125477.msg868288.html#msg868288

Only thing missing from it is listmath() at the moment.

I think that min, max etc should keep their entries in the math table as well as have their own stand alone entries?

marko

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #94 on: September 07, 2020, 05:40:09 am »

Well, they're not really Math() subfunctions at all, they now work as any other func. You can use any other func inside Math(), they're just processed from the inside out. I consider the Math() subfunctions to be the ones that *only* work inside Math().
Also, the old min/max would only take 2 args, while the new ones take N args.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Expression Language Wiki
« Reply #95 on: September 07, 2020, 03:51:15 pm »

Do the old functions still work as they used to?
Does the code for them still exist?

If so, then there should be separate Wiki entries. If not, and the new functions do replace the old, then just the external functions should be documented.

Probably requires a little testing.
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

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Language Wiki
« Reply #96 on: September 08, 2020, 02:39:21 am »

They're normal functions, not math-specific.
With math functions, you can use arithmetic within the function args, for instance:
Math(abs(3+5)) = 8

You can't do that with normal functions:
PadNumber(123, 4+1) = 0123 (not 00123)

So, testing min/max/rand inside and outside of Math:
min(10, 4+2) = 4                  => +2 is ignored
math(3 + min(10, 4+2)) = 7        => not 9, because the min() is evaluated first as an independent function

max(5, 10+3) = 10                 => +3 is ignored
math(1 + max(5, 10+3)) = 11       => not 14 as you would expect if it was a pure Math function

Rand(10, 20+1000)                 => returns numbers between 10 and 20, never above
Math(rand(10, 20+1000))           => same, rand is evaluated independently

RandN(10)                         => error, doesn't work outside of math
Math(RandN(10+1000))              => random between -1010 and 1010; the numbers are added up before calling RandN()

So this proves that Min, Max and Rand are NOT math() functions, while RandN is a math() function.
Logged
Pages: 1 [2]   Go Up