INTERACT FORUM

More => Old Versions => JRiver Media Center 26 for Windows => Topic started by: dtc on May 05, 2020, 08:02:23 am

Title: Expression Language Wiki
Post by: dtc on May 05, 2020, 08:02:23 am
This was a great effort. Thanks. However, now they need to be documented in the Wiki. Otherwise, it is somewhat hit and miss how to use them. I was looking for the syntax of Find and realized I could not find it.   The questions I had were if any of the capitalization options were implemented and if you could start the serach at someplace other than the beginning.   Nobody likes to do documentation, but we need that to make these functions useful.  Thanks.
Title: Re: Expression Language Wiki
Post by: Mike Foran on May 05, 2020, 09:05:47 am
NEW: Added a SearchTags(...) expression function that takes a value and returns all the fields that have a match (the parameter after the value is an integer that when set to 1, just returns true or false for matches instead of the field names).

SearchTags works GREAT!!!! Wow this really made my day! I'm going to have fun with this. Finally my Obsessive Tagging Disorder will pay off dividends. Thank you for implementing that!

Question: Is there any way to dynamically feed a search parameter to a search expression? For instance, Can I have a Panes view with column A being "Artist" which would feed selected names to a SearchTags query and return results either in a column B or in a lower panel content list?
Title: Re: Expression Language Wiki
Post by: marko on May 16, 2020, 05:01:00 am
These need to be added to the wiki....

I've made a start, adding "IfCase()" this morning. Just adding that one took way too long as I'm not familiar enough with wiki markup, and there seems to be multiple pages to edit just to add one function, so relied upon much copy/pasting/editing. Was also helped by wer's full description in it's proposal. Getting them all added will take literally months.

If anyone with more time on their hands feels like helping, don't hold back :)

These are added to the wiki expressions page (https://wiki.jriver.com/index.php/Expression_Language#Function_Index)
These are still to be added


Changed: Added the expression function ListMix2 that removes the escapement (so it will return with the ListMix expression).
NEW: Added a Dehexify expression function. (Bld 26)


NEW: Added the IfCase(...) expression function ( details here: https://yabb.jriver.com/interact/index.php/topic,124543.msg866100.html#msg866100 ).
NEW: Added a ListMix(...) expression function (see this thread for details: https://yabb.jriver.com/interact/index.php/topic,124543.0.html)
NEW: Added a mode to the Find(...) expression function "2" to reverse find instead of forward find in the string.
NEW: Added the expression function Letter(...) to output the starting letters of a string.
NEW: Added the expression function TrimLines(...) to standardize and consolidate newlines.
NEW: Added a SearchTags(...) expression function that takes a value and returns all the fields that have a match (the parameter after the value is an integer that when set to 1, just returns true or false for matches instead of the field names).
NEW: Added the expression function Find(...) to search for a substring in a string.
NEW: Added the expression function Trim(...) to trim non-printable characters and newlines from a string.
NEW: Added the expression function Range(...) to create a numbered list.
NEW: Added the ListShuffle(...) expression function.
NEW: Added modes 9 (List search ANY (case sensitive)), 10 (List search ANY (case insensitive)), 11 (List search ALL (case sensitive)), and 12 (List search ALL (case insensitive)) to the IsEqual expression function.
NEW: Added modes 13 through 16 to IsEqual to do full string matching (instead of partial).
NEW: The Regex expression function takes a -2 mode that outputs all the captures as a semi-colon delimited list.
NEW: Added a mode 5 to the Clean(...) expression function that standardizes quotes.
NEW: Added a ListGrep expression function to filter a list to a matching string.
NEW: Added the expression function ListFind(...) to search a list for a value (takes a final parameter to decide if it should return the value or the index).
NEW: Added the Char(...) expression function to output a character from the numeric code of the character.
NEW: Added the expression function Number(...) that takes a string and finds the number (plus decimal) in the string.
NEW: Added modes 3 (remove empty strings) and 4 (trim strings) to the ListClean(...) expression function.
NEW: Added a ListRemove expression.
NEW: Added the ListFormat(...) expression function.
NEW: Added the expression function Or(...) to test a list of values and output true if any are set.
NEW: Added the expression function And(...) to test a list of values and output true if all are set.
Rand(...)
DateInRange(...)
FileLookup(...)
IsDigit(...)
IsDriveMissing(...)
IsLowerCase(...)
IsUpperCase(...)
StackCount(...)
Row(...)
NoArticles(...)
URLify(...)
RatingStars10(...)
DBLocation(...)
NEW: Added the expression Enviro to load a system environment variable.
Translate(...)
Literal(...)
NEW: Added a GroupCountQuery(...) expression function to group files by a field, then count another field.
NEW: String literals can be defined in expressions by using /* comment here /*.  The text will be output without any formatting. (Added info to Expression Language Syntax info)
ItemCount(...) https://yabb.jriver.com/interact/index.php?topic=122319.0
NEW: Added the expression function GroupSummaryQuery to build a summary for files matching the given fields.
Changed: Made the ListFind(...) expression function support outputting a custom not found string when searching on index (keep blank to output -1).
Changed: The ListLimit(...) expression function takes a delimiter (optional and defaults to semi-colon).
NEW: Added mode 2 to the ListRemove expression function which does substring matching (instead of entire string).
NEW: The ListItem(...) expression functions optionally takes a negative number to mean from the end of the list (-1 is last, -2 is second to last, etc.).
It seems that Matt did add the ListMath() function listed here (https://yabb.jriver.com/interact/index.php/topic,124543.msg877813.html#msg877813).
NEW: Added the expression functions PadLeft(...) and PadRight(...) to pad a string.
NEW: Added a Roman(...) expression function to convert to and from roman numerals.
NEW: Added a Repeat(...) expression function to output a string over and over a given number of times.
NEW: Added the min and max expression functions (they take any number of parameters).
NEW: Added the expression functions avg and sum to average and sum numbers.
NEW: The Mid(...) expression function takes a mode so that you can pass the end as an index instead of a count of characters.
NEW: Added a match mode to the ListFind(...) expression function to switch between partial matching and full matching.
NEW: Added a Not(...) expression function to flip the state of a variable. (https://yabb.jriver.com/interact/index.php/topic,128028.msg888187.html)
NEW: Added the PlaylistTime(...) expression (https://yabb.jriver.com/interact/index.php/topic,129172.msg896429.html#msg896429)
NEW: Added the TreeNode(...) expression.  Mode 0 (the default) returns the full path.  Mode 1 returns the current item.  Mode 2 returns the parent item. (https://yabb.jriver.com/interact/index.php/topic,124543.msg897717.html#msg897717)
Extract() (https://yabb.jriver.com/interact/index.php/topic,124543.msg894801.html#msg894801)
NEW: Added the FieldQuery expression function (https://yabb.jriver.com/interact/index.php/topic,124543.msg877502.html#msg877502) to return a list of matches based on a list of fields to search.
NEW: Added the SetField(...) expression function.
NEW: Added the number 4 to the TrimLines expression function to replace triple new lines with double. (https://yabb.jriver.com/interact/index.php/topic,124543.msg902966.html#msg902966)
NEW: Added the ListFilter(...) expression function (https://yabb.jriver.com/interact/index.php/topic,124543.msg903474.html#msg903474)
NEW: Added another mode to ListCombine(...) expression function to allow outputting only values not common to both lists.
NEW: Added a checkbox to library fields "Allow custom data to override the expression" that will allow editing the value of an expression and then show the edited value instead of the expression (just empty to bring the expression back).
NEW: Added modes 7 and 8 to the Clean(...) expression to remove numbers from the end of the string ( 7 ) or either side of the string ( 8 )
Changed: Added an optional third parameter to the Counter expression function to set when to start over.
NEW: When setting a field to an expression, a "this" variable is saved so doing something like =RemoveLeft([this], 3) will work.
Additional modes for PlaylistTime() (https://yabb.jriver.com/interact/index.php/topic,133477.msg924633.html#msg924633)
Changed: Made the Field expression function take an optional third parameter to specify a file key (defaults to empty which evaluates the current file).
NEW: Made FieldQuery take a Scope of 2 to match files of the same media type (the list is gathered one time, so you will need to restart to see newly imported files). (https://yabb.jriver.com/interact/index.php/topic,124543.msg906880.html#msg906880)
Changed: ListMix allows specifying flag value of 4 to not evaluate the inner portion as another expression.
Changed: ListMix takes parameter value of 8 which tells it to do no unescape after everything.
NEW: Added a mode 3 to ListCombine that's A - B. (https://yabb.jriver.com/interact/index.php/topic,134242.msg929834.html#msg929834)
ConvertDate() updates (https://yabb.jriver.com/interact/index.php/topic,133694.msg935132.html#msg935132)
NEW: Added a CompareDates expression function to compare by year, days, or calendar years. (30.0.52)
NEW: Added IsOverridden expression function to test if an expression field has a stored value. (32.0.21) (why... (https://yabb.jriver.com/interact/index.php/topic,138260.msg959029.html#msg959029))
NEW: Added a FileExtension expression function. (32.0.13)
5. NEW: Added a Decimal expression function to convert to dot for a number.


Done
ListMix examples need attention (https://yabb.jriver.com/interact/index.php/topic,125477.msg870869.html#msg870869) (Thanks lepa)
The ListLimit() (https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListLimit) needs fleshing out a bit.
Add clarity to GroupCountQuery (https://yabb.jriver.com/interact/index.php/topic,125477.msg873874.html#msg873874)

I am illiterate when it comes to regex so could not provide an example use case for the new -2 mode. If anyone can write this up I can add it to the regex examples. Thanks to wer for some detailed regex information (https://yabb.jriver.com/interact/index.php/topic,125477.msg870799.html#msg870799).

-marko
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 16, 2020, 08:06:26 pm
I promised Matt I would document one, but then I hit this issue;

Just adding that one took way too long as I'm not familiar enough with wiki markup

I did make a start, producing a simpler list of functions to work through, and adding an earlier one that hasn't been documented, IsUpperCase(...).

Full List
IfCase(...)
ListMix(...)
Find(...)
Letter(...)
TrimLines(...)
SearchTags(...)
Trim(...)
Range(...)
ListShuffle(...)
Char(...)
Number(...)
ListFind(...)
Or(...)
And(...)
IsUpperCase(...)
ListGrep() https://yabb.jriver.com/interact/index.php/topic,124543.msg869886.html#msg869886
Regex(...) Mode -2 example: https://yabb.jriver.com/interact/index.php/topic,119385.msg870800.html#msg870800
ListRemove(...)
IsEqual(...) - Update with all the new Modes. I guess that is in your list above, but not in mine.
NEW: Added modes 3 (remove empty strings) and 4 (trim strings) to the ListClean(...) expression function.
DateInRange(...)
FileLookup(...)
IsDigit(...)
IsDriveMissing(...)
IsLowerCase(...)
NoArticles(...)       Matt, the Tooltip for this one needs to be fixed. Refers to "RemoteArticles" 
Rand(...)
Row(...)
StackCount(...)
Link to the IsEqual command in the IfCase(...) doesn't work though.
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
ItemCount(...) https://yabb.jriver.com/interact/index.php?topic=122319.0



GroupSummaryQuery(...)
GroupCountQuery(...)
DBLocation(...)
Literal(...)
RatingStars10(...)
Translate(...)
URLify(...)
Enviro variable

Min(...)
Max(...)
Avg(...)
Sum(...)
FieldQueert(...)



We also need to add to the list:
Should add a link to Boolean Operations (https://wiki.jriver.com/index.php/Boolean_Operations) as they would be helpful, but not easy to find.

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
I know of:
[Elapsed Time]
[Remaining Time]
[Total Time]
[Bitrate (labeled)]
[PN Position]
[PN Tracks]
[Zone]
[App Name]
[App Version]
[Library]
[View Filter]
[Playlist Remaining Time]

In future (MC27):
[Playlist Total Time]

From Matt 2020-07-23:
Here's the full list of specials for the player in MC27:
Alternate Settings|App Name|App Version|Bitrate|Bitrate (Labeled)|Channels|Elapsed Time|Library|Playstate|PN Position|PN Tracks|Remaining Time|Total Time|Playlist Remaining Time|Playlist Total Time|User|View Filter|Volume|Zone|Zone ID|In Sample Rate|Out Sample Rate


27.0.4 (8/22/2020)
2. Changed: Added the min and max expression functions (they take any number of parameters).
5. NEW: Added the expression functions avg and sum to average and sum numbers.
7. NEW: Added the FieldQuery expression function to return a list of matches based on a list of fields to search.
Title: Re: Expression Language Wiki
Post by: wer on May 16, 2020, 08:37:42 pm
GroupSummaryQuery and GroupCountQuery don't work correctly yet, so I'd hold off on those.
Title: Re: Expression Language Wiki
Post by: marko on May 17, 2020, 12:07:28 am
Quote
Your link to the IsEqual command doesn't work though.
I know, but don't know why. It follows the exact same syntax as FirstNotEmpty above it.

It's because, in yet another step, a redirect for every function is required. Sorted now.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 17, 2020, 01:52:23 am
Those redirects only seem to be required where you are redirecting to another point on the same page. It still wasn't working for me.

You have used this form, which redirects to another point on the same page, I think: [[#IsEqual|IsEqual()]]

To direct to a point on a different page only seems to need, I think: [[IsEqual()]]


I worked that out from the link to the If() function in the examples for the IsEqual() function on the "Test and Comparison Functions" page, which redirects to the "Conditional Functions" page.

So the text "The If() (https://wiki.jriver.com/index.php/Conditional_Functions#If) function bases its decision on the outcome of..." is coded as ": The [[If()]] function bases its decision on the outcome of...".

In fact, looking further, the second form is used to jump to a point on the same page as well. Both forms work for that. Maybe one version does use the redirect, and the other doesn't. Why not just use the full URL, which in the case of the If() function is "https://wiki.jriver.com/index.php/Conditional_Functions#If" ?   I don't know, yet.



I had to edit your IfCase() entry to test that out, as the Preview didn't really prove anything. It works now, using the second form above. 

This is why I hadn't edited these pages before, except for minor tweaks. I don't find reading the Wiki Media documentation very easy either.  ? Which is why I have avoided it.  ;D  There must be an easier way to create these pages.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 17, 2020, 02:11:32 am
Ah, it looks like that first form might be used to hide the redirect, which shows at the top of the page if you use the second form.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 17, 2020, 03:31:23 am
Hmmm. It looks like the correct form, without using a Redirect, is:

[[Test_and_Comparison_Functions#IsEqual|IsEqual()]]

Where Blue [[]] designates the start and end of a Link.
The Orange "Test_and_Comparison_Functions" is the page to go to.
The Purple "#" designates the following text is the name of an Anchor (I think that is the correct term) to go to on the above page.
The Black "IsEqual" is the name of an Anchor to go to on the above page.
The Red | designates that the following is the text to show.
The Green "IsEqual()" is the text to show in the body of the Wiki.

I suspect that using the above form doesn't require a Redirect to work, but I haven't deleted the "IsEqual" Redirect to test that. In fact, I suspect that when just the "#IsEqual" form is used in the first part, MediaWiki tries to find a page of that name, can't, and so tries to find a Redirect of that name. Although the Redirect is actually named "IsEqual()".

I just can't find a better explanation in the MediaWiki help pages at the moment.

Anyway, using this form works, makes the Wiki easier to read when editing it, and potentially doesn't need a Redirect. Good enough for me.
Title: Re: Expression Language Wiki
Post by: marko on May 17, 2020, 03:35:46 am
That's IsEqual() updated and Letter() added.
Title: Re: Expression Language Wiki
Post by: marko on May 17, 2020, 03:37:37 am
Not sure about all that linkage stuff. I can only imagine glynor set it up that way with good reason.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 17, 2020, 03:54:17 am
Maybe. having to create the Redirects seems a bit strange. I can't find any reason for that in the MediaWiki help pages. The only reason I can think of is if the Redirects are used elsewhere, so need to be created anyway. Dunno.
Title: Re: Expression Language Wiki
Post by: marko on May 23, 2020, 05:52:52 am
I could well be wrong, but I think they might be helping with searches. So, if you search for ListMix() and press enter, it takes you directly there. Either way, I've made them just to keep as much uniformity as possible.

This morning, I've added the ListMix() (https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListMix) function, with huge thanks to zybex for the comprehensive write up. I would likely as not been unable to write it up as cleanly as that. Thank you zybex.
Title: Re: Expression Language Wiki
Post by: glynor on May 23, 2020, 04:34:34 pm
I could well be wrong, but I think they might be helping with searches. So, if you search for ListMix() and press enter, it takes you directly there. Either way, I've made them just to keep as much uniformity as possible.

Correct. Each one is its own "page" in the Wiki (the pages are just redirects to the proper index of the section pages), so you can do this:
https://wiki.jriver.com/index.php/If() (https://wiki.jriver.com/index.php/If())
https://wiki.jriver.com/index.php/IsPlaying() (https://wiki.jriver.com/index.php/IsPlaying())
https://wiki.jriver.com/index.php/Regex() (https://wiki.jriver.com/index.php/Regex())

And those links will take you directly to the proper spot. That also allows you to search for the name of an expression function and be taken directly to the entry (rather than to a search page and have to find it). That's basically how the search index is built in MediaWiki. Alternate terms are always redirects.

It is also very handy for documenting functions elsewhere in the Wiki. Because if you use a function name anywhere on any page, you can just surround it with brackets and it'll automatically go to the right spot (you don't have to use "extended" mediawiki links). The idea of a MediaWiki is to keep those types of "manual deep links" to a minimum, because if you're linking to a page based on the term, it should be searchable based on that same term. Plus they're prone to breaking if you move a subsection out to its own "full" page in the future.

Therefore, add a redirect.
Title: Re: Expression Language Wiki
Post by: glynor on May 23, 2020, 04:38:57 pm
It has been a long time, but the easiest way to add functions to that section of the wiki is to copypasta a previous entry in the same section, and then modify it. Doing it that way is reasonably simple.

Then, once you've created the main entry, just click on the redlink in the "title" and make the redirect (like the others use).

Lastly, go and add them to the Function Index, and point towards the redirect page you just made (which basically happens automatically when you surround the function name with brackets).
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 23, 2020, 06:09:40 pm
Thanks Glynor.

I still haven't done one of these. But I follow why it is done that way.

So the Function Index needs to be manually updated? I always thought there was some indexing going on in the background building summaries. It looks like it needs some love. I just corrected one small error produced by Copy/Paste (GroupSummary). I think I corrected that previously in the main Expression Language page, not knowing about the Function Index needing separate update. The correction is there, but it isn't showing in History. Strange.
Title: Re: Expression Language Wiki
Post by: glynor on May 23, 2020, 09:12:36 pm
So the Function Index needs to be manually updated?

It does, unless someone else built something much fancier than I did when I last left it. My guess is that errors were introduced as others made edits not fully understanding the system, though it is possible that I left it behind with some errors of my own.

Auto-generated content like you were envisioning can be done, but it is substantially complex, and requires server-side scripting that I didn't have access to add (nor the knowledge or desire to implement it and maintain it).
Title: Re: Expression Language Wiki
Post by: glynor on May 23, 2020, 09:21:06 pm
I should note...

This Function Index is wrong: https://wiki.jriver.com/index.php/Function_Index
It should be a redirect to here: https://wiki.jriver.com/index.php/Expression_Language#Function_Index

I think that was an cruddy page that 6233638 made long ago (because he didn't understand the setup of the main page). Then it looks like Marko and others have been trying to fix it, but it should have just been made into a redirect to the Function Index in the Expression Language article. It isn't needed, and is just a duplicate place to have to edit everything.

Edit: I fixed it. If you added anything useful to 6233638's weird Function Index page, you'll need to look at the history and move them to the proper Function Category sub-page.

Oh, and the reason why I split it up into sub-pages is because there was WAY too much on one page to be able to edit it in a manageable fashion.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 23, 2020, 09:55:22 pm
Now that makes a lot more sense. You fixed it and edited that post while I was typing. Ta.

The sub-pages make a lot of sense. One big page would be a nightmare.

It looks like the three new functions added so far are on the main page already, so all good, thanks to Marko.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 23, 2020, 11:11:29 pm
Okay, there is still something funky going on with the IsEqual link in the IfCase section, as per my reply 8 above.

I removed my direct link and put back the correct link in the form [[#IsEqual|IsEqual()]]. It doesn't work, just linking back to the top of the "Conditional Functions" page, rather than jumping to the "IsEqual" on the "Test and Comparison Functions" page.

The redirect looks correct and works correctly. It hasn't been edited since you created it Glynor.

When I hover over the link it shows the incorrect information, pointing to "https://wiki.jriver.com/index.php/Conditional_Functions#IsEqual" instead of the correct "https://wiki.jriver.com/index.php/Test_and_Comparison_Functions#IsEqual", as seen in other instances of using that same redirect on other pages, with the exact same form of link in the other pages, being "[[#IsEqual|IsEqual()]]". There is no error in the text, and yet the link in the IfCase section doesn't work correctly.

I tried deleting that link, saving the page, and recreating the link again, and it still doesn't work. I can't see what the problem is.

It seems like MediaWiki has remembered that link for that section, and it isn't going to forget it or update the page no matter what. I've looked at the Redirect every way I can, done searches and compared the results to other functions. I just can't see a fix for this issue.

Sure, I could just put the direct link back, but what if the next one doesn't work?


PS: Marko, when I first tried the link in the form [[#IsEqual|IsEqual()]] after you set it up, it didn't work then either. It always jumped to the top of the "Conditional Functions" page.


Nope. I come back to the same thing I said in Reply 8. That form of link only works to jump to a location on the same page. It does not use the Redirect, and hence doesn't jump to a location on another page. As evidence, I direct anyone interested to the Expression Language Archive page (https://wiki.jriver.com/index.php/Expression_Language_Archive), which uses the same form and only redirects back to locations on the same page.
Title: Re: Expression Language Wiki
Post by: marko on May 24, 2020, 01:54:54 am
This wiki editing discussion should be moved to its own thread...

The IsEqual link in the IfCase description has been fixed using [[Test and Comparison Functions#IsEqual|IsEqual()]] (as per reply #10)

Regarding copy/paste...
This is the markup used for the listcombine function, which is about as unuser friendly as you could get....
Code: [Select]
=== <span id="ListCombine">ListCombine(&hellip;)</span> ===
: Combines two delimited lists into a single delimited list.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="ListCombine" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listcombine(</b><i>list1</i><b>, </b><i>list2</i><b>, </b><i>input delimiter</i><b>, </b><i>output delimiter</i><b>, </b><i>mode</i><b>)</b></span>
The [[#ListCombine|ListCombine()]] function returns a single list after performing the operation specified by <i>mode</i> on the two lists <i>list1</i> and <i>list2</i>.
An <i>input delimiter</i> and an <i>output delimiter</i> may be specified.
The <i>input delimiter</i> is effective for both <i>list1</i> and <i>list2</i>, and the <i>output delimiter</i> will be used in the returned list, replacing the
<i>input delimiter</i> from both <i>list1</i> and <i>list2</i>.

Available <i>mode</i> values:

<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
<tr><td style="text-align:left; padding-right:20pt"><b>0</b></td><td>Combine lists removing duplicates (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Output only items contained in both lists (order is preserved).</td></tr>
</table></div>

Argument <i>input delimiter</i> is optional (defaults to SEMICOLON).

Argument <i>output delimiter</i> is optional (defaults to SEMICOLON).

Argument <i>mode</i> is optional (defaults to 0).

|- valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcombine(a;b;e, a;b;c;d)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a;b;e;c;d</span>.
This example uses the default <i>mode</i> 0 to combine <i>list1</i> with <i>list2</i>, preserving the order of items.
The default <span style="font-family: monospace,monospace; font-size:1em;">;</span> <i>input delimiter</i> and <i>output delimiter</i> is used.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcombine(a;b;e, a;b;c;d, ;, ;, 1)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a;b</span>.
The <i>input delimiter</i> and <i>output delimiter</i> are both specified as <span style="font-family: monospace,monospace; font-size:1em;">;</span>,
and <i>mode</i> 1 is used to produce a list of only items that exist in both <i>list1</i> and <i>list2</i>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcombine(a-c, c-f, -, ..., 0)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a...c...f</span>. The <i>input delimiter</i> is <span style="font-family: monospace,monospace; font-size:1em;">-</span>, while the <i>output delimiter</i> is <span style="font-family: monospace,monospace; font-size:1em;">...</span>, and <i>mode</i> 0 combines both lists.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcombine(a#@#c, c#@#f, #@#, ., 0)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a.c.f</span>. This example demonstrates how to combine two lists with duplicates removed while replacing a multi-character <i>input delimiter</i> <span style="font-family: monospace,monospace; font-size:1em;">#@#</span> with a single-character <i>output delimiter</i> <span style="font-family: monospace,monospace; font-size:1em;">.</span>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcombine([people], [places])&amp;datatype=[list]</nowiki></b></span>
<p style="margin-left:20pt;">The result here would be a single, semicolon delimited list containing all the list items from the [people] and [places] fields.
For example, if [people] contains <span style="font-family: monospace,monospace; font-size:1em;">Family\Mum; Family\Dad; Family\Gran</span>, and [places] contains <span style="font-family: monospace,monospace; font-size:1em;">UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle</span>,
the output list would be <span style="font-family: monospace,monospace; font-size:1em;">Family\Mum; Family\Dad; Family\Gran; UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle</span>.
Using the <span style="font-family: monospace,monospace; font-size:1em;">&datatype=[list]</span> cast makes the expression split individual list items in a panes or categories view.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

This, is the markup used for listmix, which is a whole lot easier to follow...
Code: [Select]
=== <span id="ListMix">ListMix(&hellip;)</span> ===
: Combine corresponding values from multiple lists into a new list, using a template to process each item.

{{function description box
| name=ListMix
| arguments=template, mode, list1, [list2, ... listN]
| description=
{{argument optional|mode|0}}
The [[#ListMix|ListMix()]] function processes the elements of one or more lists, returning a new list where each element is similar to the provided template modified with the elements of the list argument(s).
The number of list arguments to be mixed is variable, but at least one must be provided. The lists can have different lengths, with mode controlling the length of the returned list.
The first element of the returned list is generated by applying the first element of each provided list to the template; the second element is generated using the second element(s) of the list(s), and so on until all elements are processed, according to mode.

The <i>'''template'''</i> is a text string with placeholders like [L1], [L2], etc, indicating where the elements of the provided lists should be inserted. [L1] refers to elements of list1, [L2] refers to list2, and so on. The special placeholder [N] refers to the item number within the resulting list.

A <i>'''template'''</i> is also itself an Expression, so it can contain other functions/expressions. A template can be escaped using the escape sequence /#template#/. This is usually not required but may be useful to enter templates containing functions, commas, or other special symbols.

The default semi-colon list delimiter is used for both input and output lists.

{{argument table
| name=mode
| contents=
{{argument table row|0|Return as many elements as the '''longest''' provided list}}
{{argument table row|1|Return as many elements as the '''shortest''' provided list}}
{{argument table row|2|Return as many elements as the '''first''' provided list}}

}}
| examples=
'''{{monospace|<nowiki>ListMix(Actor #[N] is [L1],, a;b;c)</nowiki>}}'''
: Returns Actor #1 is a; Actor #2 is b; Actor #3 is c
This example uses mode 0 and demonstrates the usage of [N] and [L1] on a single list.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 0, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns a1=blue; b2=red; c3=green; d4=; =5
Mode 0 returns 5 elements which is the length of the longest list. Note that on the last two the missing values on the template are also missing on the output.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 1, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns a1=blue; b2=red; c3=green
: Mode 1 returns only 3 elements, the length of the shortest list.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 2, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns : a1=blue; b2=red; c3=green; d4=
: Mode 2 returns only 4 elements, the length of the first list.

'''{{monospace|<nowiki>ListMix(FixCase([L1],3)=Math([L2]*[L3]),, aa;bb;cc, 10;20;30, 5;4;3)</nowiki>}}'''
: Returns : AA=50; BB=80; CC=90
: This example uses two different functions on the template to further transform each element of the lists before inserting it into the output.


'''{{monospace|<nowiki>ListMix(<img src=tooltip:actors\\[L1]> \ , 1, [Actors], 1;2;3;4;5)</nowiki>}}'''
: Returns (example): <img src=tooltip:actors\Daisy Ridley>  ;<img src=tooltip:actors\Adam Driver>  ;<img src=tooltip:actors\John Boyega>  ;<img src=tooltip:actors\Oscar Isaac>  ;<img src=tooltip:actors\Mark Hamill> 
: This example transforms the [Actors] field into a list of <img> tags ready to load the actor thumbnails into the Theather View or Movie Tooltip. It uses mode 1 (shortest list) with a dummy [L2] list of 5 elements to make sure the resulting list is at most 5 items long. An alternative way to accomplish the same would be to use ListLimit([Actors],5) as [L1].

}}

My quest to learn more about this apparent shorthand led me to this page (https://wiki.jriver.com/index.php?title=Template:Function_description_preset&redirect=no) which helps, a lot :D
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 24, 2020, 02:26:56 am
This wiki editing discussion should be moved to its own thread...

Agreed. Needs an administrator. Really, the discussion should happen for specific articles mostly in the Wiki Discussion area of each article. But there probably should be a Wiki editing forum for broader discussion. It might encourage more people to write articles.


The IsEqual link in the IfCase description has been fixed using [[Test and Comparison Functions#IsEqual|IsEqual()]] (as per reply #10)

I changed it to that because I thought it was the correct way to do it, and the only way that worked. I changed it back because it sounded like it should work. Obviously not. I shall undo the change. EDIT: I see you already have Marko.



My quest to learn more about this apparent shorthand led me to this page (https://wiki.jriver.com/index.php?title=Template:Function_description_preset&redirect=no) which helps, a lot :D

I can read and understand all the formating on that template page, and most of the stuff above. But write it from scratch? Nah. It is a seriously complex formating language in need of a simple GUI. Word is complex, but does the same things in a far easier manner.

Title: Re: Expression Language Wiki
Post by: marko on May 24, 2020, 02:37:18 am
At its most basic, click to edit the template page, copy, cancel out of the edit page, and use clipboard to paste where the addition is going. Place text in the appropriate places and save. Job done.

It's not quite that simple, I know, but this is a massive help.

Quote
I changed it to that because I thought it was the correct way to do it, and the only way that worked. I changed it back because it sounded like it should work. Obviously not. I shall undo the change.
I had already fixed it. There are plenty of these dotted throught the various expression function descriptions. I have stumbled across at least three by accident. No, I didn't fix them because I could'nt risk losing the current place in my mind for the expression I was adding at the time and knew I would get sidetracked onto a massively time consuming tangent!

A bit like this morning, where I sat down to add Find() to the wiki over an hour ago, and have not even started yet :)

-marko.
Title: Re: Expression Language Wiki
Post by: marko on May 24, 2020, 05:59:40 am
Find() (https://wiki.jriver.com/index.php/String_Manipulation_Functions#Find) has now been added.

Could someone verify that if searching from the end of the string, any specified "start" argument is ignored and the search is always conducted from the very end?

-marko.
Title: Re: Expression Language Wiki
Post by: dtc on May 24, 2020, 10:10:35 am
Thanks for you efforts Marko. Documentation is never fun, but with the vagaries of the WIki format it is even more challenging.

For Find, I agree that the Start value is ignored for mode 3. In fact, even a  negative value for Start is ignored, whereas for the other modes a negative value for Start always returns -1.
Title: Re: Expression Language Wiki
Post by: glynor on May 24, 2020, 01:33:59 pm
My quest to learn more about this apparent shorthand led me to this page (https://wiki.jriver.com/index.php?title=Template:Function_description_preset&redirect=no) which helps, a lot :D

Well, yes. Best to copypasta one of the ones where I used the nice template I made, and not one of the ones done manually.

In some cases, the entries were just created before I made the template. In others, I was repurposing the content made by MrC (who was, himself, repurposing content made by you, marko), and re-doing them with the template was more work than just copypasta.

And, of course, all of my comments here are based on memory of things I was doing over 4 years ago, so.... YMMV.
Title: Re: Expression Language Wiki
Post by: glynor on May 24, 2020, 01:50:14 pm
Another tip: For many of the things I heavily edited, I kept "notes" on my Wiki page (including a "test/template" of the Function Description template I made). Can be useful for instructional purposes (and copypasting): https://wiki.jriver.com/index.php/User:Glynor
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 24, 2020, 08:17:29 pm
Added

ListEqual(...)
ListContains(...)
MoveArticles(...)
UnmoveArticles(...)

To the Function Index (https://wiki.jriver.com/index.php/Expression_Language#Function_Index).

Reordered (alphabetised) and cleaned up the String Manipulation Functions (https://wiki.jriver.com/index.php/String_Manipulation_Functions) a bit.


Confirmed that the following functions are not described in the wiki. Source of list (https://yabb.jriver.com/interact/index.php/topic,122288.msg846381.html#msg846381) was Moe.

DateInRange(...)
DBLocation(...)
FileLookup(...)
IsDigit(...)
IsDriveMissing(...)
IsLowerCase(...)
Literal(...)
NoArticles(...)       Matt, the Tooltip for this one needs to be fixed. Refers to "RemoteArticles"  ?
Rand(...)
RatingStars10(...)
Row(...)
StackCount(...)
Translate(...)
URLify(...)

I added these to my list above (https://yabb.jriver.com/interact/index.php/topic,125477.msg868339.html#msg868339), so they are all in one place.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 24, 2020, 10:35:56 pm
SearchTags() (https://wiki.jriver.com/index.php/Test_and_Comparison_Functions#SearchTags) has been added.


Added a Redirect for ListShuffle().
Title: Re: Expression Language Wiki
Post by: marko on May 25, 2020, 12:03:28 am
Thanks Rod. I nipped in and added the available modes to it.

Had no idea so many had fallen under the rader. Will try and get some more done next weekend. As I've been deemed an essential worker, I have to go in... It can be a little worriesome, especially when I find myself around care homes.

-marko
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 25, 2020, 12:19:47 am
Ah, I missed the table for mode. So many screens open to check what to do where. I could have picked a better example to Copy/Paste to start from. Oh well, getting some stuff done.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 25, 2020, 12:39:09 am
ListShuffle() (https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListShuffle) was actually done by Matt in March, but the Redirect wasn't correct. Fixed.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 25, 2020, 03:00:12 am
Range() (https://wiki.jriver.com/index.php/Miscellaneous_Functions#Range) has been added.

even the simple ones take a lot of time. Maybe because I am testing the functions to breaking point.
Title: Re: Expression Language Wiki
Post by: JimH on May 25, 2020, 06:48:05 am
Thanks for you work on this, Rod and Mark.
Title: Re: Expression Language Wiki
Post by: marko on May 27, 2020, 11:34:04 am
We're getting there...

added "NEW: The Regex expression function takes a -2 mode that outputs all the captures as a semi-colon delimited list." to the todo list.

-marko
Title: Re: Expression Language Wiki
Post by: marko on May 28, 2020, 11:25:11 am
added "NEW: Added a mode 5 to the Clean(...) expression function that standardizes quotes." to the todo list.
Title: Re: Expression Language Wiki
Post by: RoderickGI on May 28, 2020, 05:14:12 pm
 :o  The list is getting bigger rather than smaller!

I'll get back to doing some more soon. Did you know that MediaWiki has a WYSIWYG Editor, VisualEditor (https://en.wikipedia.org/wiki/VisualEditor)? That would be nice, although it doesn't get a good writeup.
Title: Re: Expression Language Wiki
Post by: marko on May 31, 2020, 03:23:30 am
Regex() and Clean() are now updated. Clean() was also missing mode 4! I am illiterate when it comes to regex so could not provide an example use case for the new -2 mode.
Title: Re: Expression Language Wiki
Post by: marko on May 31, 2020, 05:27:06 am
Trim() and TrimLines() are added. Half a dozen missing redirect pages created, along with a currently intentionally orphaned, flat, alphabetical list of functions (https://wiki.jriver.com/index.php/Complete_Expression_Language_Alphabetical_List) page.
Title: Re: Expression Language Wiki
Post by: marko on June 06, 2020, 05:13:25 am
ListGrep() and ListFind() are done.
Title: Re: Expression Language Wiki
Post by: wer on June 07, 2020, 09:05:16 pm
Thanks for doing these updates, guys.

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.

For example:
[\w\s]+
is a perfectly valid regular expression that returns results, everywhere, except MC.

To work in MC, it must be modified, as so:
([\w\s]+)
Putting parens around it creates a capture group, and that is the only way MC will return a result.

Second, all the old Regex() functionality (meaning everything except the new -2 mode) will return exactly one result for each defined capture group.

Third, one must be careful working with strings of indeterminate length, or lists with an indeterminate number of elements, as if you have more capture groups in your expression that there exist matches in the string, Regex() will return NOTHING.

Regex-2 was devised specifically to get around the above issues, which made it almost impossible to deal with lists a variable number of elements using regular expressions in MC.

Lastly, here's an example for Regex-2, to extract the names of the actors from a list that contains actors and roles.
[Actors]=F. Murray Abraham [Antonio Salieri];Tom Hulce [Wolfgang Amadeus Mozart];Elizabeth Berridge [Constanze Mozart];Roy Dotrice [Leopold Mozart];Simon Callow [Emanuel Schikaneder];Christine Ebersole [Katerina Cavalieri];Jeffrey Jones [Emperor Joseph II];Barbara Bryne [Mrs. Weber]

Regex([Actors],/#([\w\s\.]+(?=\s\[))#/,-2)
returns:
F. Murray Abraham;Tom Hulce;Elizabeth Berridge;Roy Dotrice;Simon Callow;Christine Ebersole;Jeffrey Jones;Barbara Bryne

The reason I gave you those notes first through third is that they are all non-standard and undocumented, and so anyone that knows regular expressions will stumble around trying to understand why normal things are not working as expected.


-Will
Title: Re: Expression Language Wiki
Post by: wer on June 07, 2020, 10:01:12 pm
Also, GroupSummaryQuery and GroupCountQuery appear to be working ok now.
Title: Re: Expression Language Wiki
Post by: marko on June 07, 2020, 11:47:03 pm
Marko, if I may, a little feedback/info on the Regex-2 documentation...
Thanks Will, exactly what was needed. I'll get it mashed into the wiki page next weekend.

I almost had Char() added but stumbled... I messed around with it a bit...
Char(189) returns ½
\u25CF/ returns a syntax error
u25CF returns nothing
https://yabb.jriver.com/interact/index.php/topic,124543.msg862539.html#msg862539

I could just add it as-is, but couldn't see any useful reason for its existance to convey in the addition, and where possible, I like to try and do that as I believe it helps people using the expression function pages to learn from, to fully realise the potential they have at their disposal.
Title: Re: Expression Language Wiki
Post by: wer on June 08, 2020, 02:30:08 am
Regarding Char(), the intention for Char(189) is as you saw, to use the ASCII code to produce a character.

Perhaps Matt didn't add the unicode support? I see no mention of it in the expression editor tooltip.


Regarding Regex-2, there is a hidden gotcha:
Multiple capture groups return invalid results, but that may be a bug.
Nested parenthesis create duplicate results, so one must avoid nested parenthesis.

Example:
(\d) is a valid capture group
(\w) is a valid capture group
(\d)|(\w) is a valid expression, but returns invalid results in MC
((\d)|(\w))  is a valid expression, but returns duplicate results in MC
(\d|\w)  is a valid expression, but and returns correct results in MC
Title: Re: Expression Language Wiki
Post by: Hendrik on June 08, 2020, 02:56:33 am
Multiple capture groups return invalid results, but that may be a bug.

Multiple capture groups seem to work fine. I suppose it depends what you define as "invalid". We try to keep the output consistent, independent of the input string, so that eg. optional captures always get an empty entry in the resulting token list.
As a consequence of that, if you use alternate captures, you also get one entry for every alternate capture group, even though only one will ever be filled, since technically they act like optional captures. The solution is of course to move the alternate into the capture if you don't want that.

The alternative is to not actually fill in results for not-matched optional captures, however you wouldn't like that, since the returned indices no longer match their group position.
The regex engine does not differentiate between these situations, so its either the current behavior or skipping empty optional captures - which IMHO is worse, since that has no easy workaround.

Nested parenthesis create duplicate results, so one must avoid nested parenthesis.

This seems to be pretty normal behavior.
Throw any such regex at https://regex101.com/ or https://regexr.com/, and it shows you two captures of the same string, as will MC.

Do note that we are using ECMAScript Regex syntax, and not PCRE, which you seem to be under the misconception of.

Not returning results without a capture group is entirely intentional. In absence of any captures, we could return the entire matched string, but I feel like its better to explicitly request which part you want returned.

You seem to be representing the old Regex mode as entirely flawed and broken, but you should remove the "g" modifier from testing in other regex tools and you'll notice that it suddenly behaves quite in the same way.
One result per capture group.  Not enough string to fill all captures? You get nothing.
Title: Re: Expression Language Wiki
Post by: wer on June 08, 2020, 03:33:32 am
Multiple capture groups seem to work fine. I suppose it depends what you define as "invalid".
See my post here for an example.  https://yabb.jriver.com/interact/index.php/topic,124543.msg870827.html#msg870827
I don't think returning a list with a bunch of empty elements is a good idea.  Someone might want to display it or use the resulting list for something else, and now you have an ugly hard to read list with a lot more elements than you had matches, and a lot more elements than can be used. I don't see the good in that.

Do note that we are using ECMAScript Regex syntax, and not PCRE, which you seem to be under the misconception of.

You seem to be representing the old Regex mode as entirely flawed and broken, but you should remove the "g" modifier from testing in other regex tools and you'll notice that it suddenly behaves quite in the same way.
One result per capture group.  Not enough string to fill all captures? You get nothing.
Well, your current usage was only recently revealed. I was foolish enough to believe what had been written in the forum and wiki, sorry.

Re entirely flawed and broken, not at all. It's good for lots of things. But it is problematic to use against a string when you want to get all the matches, but don't know how many matches there will be.
Title: Re: Expression Language Wiki
Post by: Hendrik on June 08, 2020, 03:37:24 am
See my post here for an example.  https://yabb.jriver.com/interact/index.php/topic,124543.msg870827.html#msg870827
I don't think returning a list with a bunch of empty elements is a good idea.  Someone might want to display it or use the resulting list for something else, and now you have an ugly hard to read list with a lot more elements than you had matches, and a lot more elements than can be used. I don't see the good in that.

As I explained above, its an artifact of another feature which is good and has no workaround otherwise, and this is easy enough to work around by just moving a pipe character a bit. And actually the number of entries in the list matches the number of matches perfectly. You just don't count them the same way as the program does. :)

It literally cannot be "fixed" without making optional captures practically unusable.
Title: Re: Expression Language Wiki
Post by: zybex on June 08, 2020, 04:46:21 am
I almost had Char() added but stumbled... I messed around with it a bit...
Char(189) returns ½
\u25CF/ returns a syntax error
u25CF returns nothing

It only takes decimal values. 0x25CF = 9679 decimal, so Char(9679) works.
Title: Re: Expression Language Wiki
Post by: zybex on June 08, 2020, 04:48:21 am
Regarding the regex -2 multiple-captures, I think it's OK and desirable:
https://yabb.jriver.com/interact/index.php/topic,124543.msg870844.html#msg870844
Title: Re: Expression Language Wiki
Post by: lepa on June 08, 2020, 08:49:54 am
https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListMix

Last example is little strange.
Quote
ListMix(<img src=tooltip:actors\\[L1]> \ , 1, [Actors], 1;2;3;4;5)

    Returns (example): <img src=tooltip:actors\Daisy Ridley>  ;<img src=tooltip:actors\Adam Driver>  ;<img src=tooltip:actors\John Boyega>  ;<img src=tooltip:actors\Oscar Isaac>  ;<img src=tooltip:actors\Mark Hamill>

Shouldn't i be something like this instead
Code: [Select]
ListMix(<img src=tooltip:actors\[L1]>, 1, [Actors], 1;2;3;4;5)

Returns (example): <img src=tooltip:actors\Daisy Ridley>;<img src=tooltip:actors\Adam Driver>;<img src=tooltip:actors\John Boyega>;<img src=tooltip:actors\Oscar Isaac>;<img src=tooltip:actors\Mark Hamill>
(You could use also "[L1]>/  " to add those spaces but maybe it just add unnecessary complexity here were we illustrate functionaliy of ListMix)
Title: Re: Expression Language Wiki
Post by: zybex 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...
Title: Re: Expression Language Wiki
Post by: wer 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!
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: marko 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() (https://wiki.jriver.com/index.php/Miscellaneous_Functions#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
Title: Re: Expression Language Wiki
Post by: wer 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
Title: Re: Expression Language Wiki
Post by: marko on June 15, 2020, 12:00:02 am
Sorted. Thanks for the information to put there :)
Title: Re: Expression Language Wiki
Post by: zybex 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
Title: Re: Expression Language Wiki
Post by: marko on June 21, 2020, 06:39:08 am
Sorted. Also added it to the misc. expressions section.
Title: Re: Expression Language Wiki
Post by: zybex 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.
Title: Re: Expression Language Wiki
Post by: marko 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.
Title: Re: Expression Language Wiki
Post by: marko 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?
Title: Re: Expression Language Wiki
Post by: zybex on July 04, 2020, 04:30:58 am
Same with URLify(), not sure what it's suppose to do. Hexify() works.
Title: Re: Expression Language Wiki
Post by: RoderickGI 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)
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: marko 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() (https://yabb.jriver.com/interact/index.php/topic,125477.msg869140.html#msg869140) 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() (https://wiki.jriver.com/index.php/List_Manipulation_Functions#ListLimit) could be tidied up and fleshed out a bit too.

We're almost there...
Title: Re: Expression Language Wiki
Post by: RoderickGI on July 05, 2020, 02:51:54 am
I did a bit of alphabetising some time back, if I recall correctly.

Range() (https://yabb.jriver.com/interact/index.php/topic,125477.msg869140.html#msg869140) 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() (https://wiki.jriver.com/index.php/List_Manipulation_Functions#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.
Title: Re: Expression Language Wiki
Post by: marko 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:


-marko
Title: Re: Expression Language Wiki
Post by: zybex 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.
Title: Re: Expression Language Wiki
Post by: RoderickGI 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).
Title: Re: Expression Language Wiki
Post by: marko 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
Title: Re: Expression Language Wiki
Post by: RoderickGI 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() (https://wiki.jriver.com/index.php/File_Path_and_Identifier_Functions#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.
Title: Re: Expression Language Wiki
Post by: zybex 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).
 
Title: Re: Expression Language Wiki
Post by: marko 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 :)
Title: Re: Expression Language Wiki
Post by: JimH on July 05, 2020, 07:35:11 am
Thanks for the help!
Title: Re: Expression Language Wiki
Post by: RoderickGI 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
Title: Re: Expression Language Wiki
Post by: glynor 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...
Title: Re: Expression Language Wiki
Post by: RoderickGI 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. :-/#/)

Title: Re: Expression Language Wiki
Post by: glynor 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.
Title: Re: Expression Language Wiki
Post by: RoderickGI 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 (https://wiki.jriver.com/index.php/String_Manipulation_Functions#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.
Title: Re: Expression Language Wiki
Post by: zybex 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 /# #/...
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: Hendrik 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! :)
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: glynor 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.
Title: Re: Expression Language Wiki
Post by: zybex 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!]
Title: Re: Expression Language Wiki
Post by: marko on July 12, 2020, 12:57:03 pm
Is this all correct?
https://wiki.jriver.com/index.php/Grouping_Functions#GroupCountQuery

Title: Re: Expression Language Wiki
Post by: wer 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.
Title: Re: Expression Language Wiki
Post by: marko 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() (https://wiki.jriver.com/index.php/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 (https://wiki.jriver.com/index.php/TV_Episodes#Tweaks_to_Theater_View).

@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 (https://wiki.jriver.com/index.php/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 (https://wiki.jriver.com/index.php/Function_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 (https://yabb.jriver.com/interact/index.php/topic,125477.msg868288.html#msg868288) which will hopefully be boxed off next weekend.

-marko
Title: Re: Expression Language Wiki
Post by: JimH on July 19, 2020, 07:48:53 am
Thanks, Marko.  And wer.
Title: Re: Expression Language Wiki
Post by: zybex 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.
Title: Re: Expression Language Wiki
Post by: marko on July 25, 2020, 02:48:19 am
For me, we're all done (https://yabb.jriver.com/interact/index.php/topic,125477.msg868288.html#msg868288). 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
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: zybex 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
Title: Re: Expression Language Wiki
Post by: marko 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
Title: Re: Expression Language Wiki
Post by: zybex 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.
Title: Re: Expression Language Wiki
Post by: RoderickGI 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.
Title: Re: Expression Language Wiki
Post by: zybex 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.