INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 6 7 ... 9   Go Down

Author Topic: Expression functions [HELP WANTED]  (Read 62863 times)

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #100 on: April 27, 2020, 12:42:50 pm »

Yes, that's right, and that's what I intended.  I just wasn't paying much attention when I wrote the examples, I was trying to include things of different types.  I'll update the examples for posterity.

Thanks Matt!
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Expression functions [HELP WANTED]
« Reply #101 on: April 27, 2020, 08:44:33 pm »

Would there be a way to make commands like IsEqual() operate on lists with ANY/ALL operators?
I find that I often end up writing needlessly complicated expressions because I have to use nested repeating commands.
Perhaps with a couple of new modes?

 9   List search ANY (case sensitive)
10   List search ANY (case insensitive)
11   List search ALL (case sensitive)
12   List search ALL (case insensitive)

For example, replacing:
Code: [Select]
If(IsEqual([Album Artist (auto)], various, 8), [Artist], If(IsEqual([Album Artist (auto)], multiple, 8), [Artist], [Album Artist (auto)]))

With:
Code: [Select]
If(IsEqual([Album Artist (auto)], various; multiple, 10), [Artist], [Album Artist (auto)])

There are other functions where this could be useful too.
I seem to remember having some expressions with a lot of needlessly complicated nested Replace() commands; e.g.
Code: [Select]
Replace(Replace(Replace([Album], :, ꞉), ?, ?), //,⧸)
(this is because MC replaces illegal characters with _ instead of good substitutes)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #102 on: April 29, 2020, 09:44:47 am »

Good idea!

Next build:
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.
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #103 on: April 29, 2020, 12:15:16 pm »

For any and all, I don't see from the example how we're suppose to pass the multiple substrings.  Is it a list with a delimiter?  I don't get it.

Would it make more sense to make isequal or ifcase accept boolean operators on arguments?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #104 on: April 29, 2020, 12:19:26 pm »

For any and all, I don't see from the example how we're suppose to pass the multiple substrings.  Is it a list with a delimiter?  I don't get it.

Would it make more sense to make isequal or ifcase accept boolean operators on arguments?

Here's a simple example:
IsEqual(a;b;c, a;b, 9) = 1
IsEqual(a;b;c, a;b, 11) = 0
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #105 on: April 29, 2020, 12:48:43 pm »

Those are a little too simple, because they already have equivalents:   
IsEqual(a;b;c, a;b, 9) == IsEqual(a;b;c, a;b, 7)
IsEqual(a;b;c, a;b, 11) == IsEqual(a;b;c, a;b, 0)

What do these do?

IsEqual(Moe/, Larry and Curly, Curly;Bob, 9)= ?
IsEqual(Moe/, Larry and Curly, Curly;Moe;Larry, 11)= ?


Also, Matt, don't forget if you're adding modes to IsEqual, they need to also be added to IfCase.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #106 on: April 29, 2020, 01:01:36 pm »

IsEqual(Moe/, Larry and Curly, Curly;Bob, 9)= ?

There's no Bob in the first string or Curly, so no match.  The match string is "Larry and Curly" which "Curly" isn't enough to match.

IsEqual(Moe/, Larry and Curly, Curly;Moe;Larry, 11)= ?

It's search all, and all don't match.  So zero again.
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #107 on: April 29, 2020, 01:11:39 pm »

There's no Bob in the first string or Curly, so no match.  The match string is "Larry and Curly" which "Curly" isn't enough to match.

It was mode 9, ANY, so I would have expected a match if ANY of the second list was in the first.

Quote
It's search all, and all don't match.  So zero again.

All three elements in the 2nd list are present in the first. I would expect a match.

What you're describing is no different than what we already have.  What's an example where this actually does something new?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #108 on: April 29, 2020, 02:07:06 pm »

What you're describing is no different than what we already have.  What's an example where this actually does something new?

A simple case that returns a match when I'm not aware of other functions that would:
IsEqual(a;b,b;a,11)
Logged
Matt Ashland, JRiver Media Center

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Expression functions [HELP WANTED]
« Reply #109 on: April 29, 2020, 02:26:35 pm »

It was mode 9, ANY, so I would have expected a match if ANY of the second list was in the first.
All three elements in the 2nd list are present in the first. I would expect a match.

I think you are misunderstanding the functionality. Here's a formal description:

ALL: Given a list A and a list B, IsEqual(A,B,9) returns TRUE if ALL elements of list B are present in list A, regardless of ordering of both lists
ANY: Given a list A and a list B, IsEqual(A,B,11) returns TRUE if AT LEAST ONE element of list B is present in list A

For the examples you gave:
Code: [Select]
IsEqual(Moe/, Larry and Curly, Curly;Bob, 9)= ?List A has only 1 element ("Moe/, Larry and Curly"), and list B has 2 elements which are both NOT in list A. So this returns FALSE. Keep in mind that the string must match in its entirety - "Moe/, Larry and Curly" is not equal to "Curly".  This function is the same as checking if an Intersect of the 2 lists is empy or not.

Code: [Select]
IsEqual(Moe/, Larry and Curly, Curly;Moe;Larry, 11)= ?List A is still only 1 element, and it's distinct from all 3 elements in the second list - so, ALL = false. This function is the same as checking if an Intersect of A and B returns all elements of B.

My own examples:
IsEqual(Moe;Larry and Curly;John, Jake;John;Bob, 9)    => true because John is in both lists
IsEqual(Moe;Larry and Curly;John, Jake;Curly;Bob, 9)   => false because no element of the second list is in the first list
IsEqual(Moe;Larry and Curly;John, John;Moe, 11)        => true because both John and Moe are in the first list
IsEqual(Moe;Larry and Curly;John, Curly;John;Moe, 11)  => false because Curly is not on first list (by itself)

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #110 on: April 29, 2020, 02:30:36 pm »

Ok there's only one difference between my example

IsEqual(Moe/, Larry and Curly, Curly;Moe;Larry, 11)

and yours

IsEqual(a;b,b;a,11)

What I think you're saying is that what you're envisioning is something that only works on delimited lists, and only compares against whole elements of the lists.

I was thinking of something more flexible, where the list to be searched could be delimited or undelimited, and where the interpreter is performing AND or OR operations on the elements of the second list.

My interpretation answers the question "are any or all of the elements in the second list present in the first string"
Yours answers "are any or all of the elements in the second list also individual elements of the first list"

Mine would match on both of the examples, yours only matches when the first list is delimited.

The approach I was envisioning can perform the same function as yours:
IsEqual(Moe/, Larry and Curly, /;Curly/;, 11) = 0
but yours doesn't work against undelimited lists.

I suggest that the more flexible approach is better, because the user can user more or less  restrictive matching at will.

IsEqual([Actors], Meryl, 11) = 1  with yours won't work. You would have to have an exact match, like "Meryl Streep" or if roles are present "Meryl Streep [Joanna Kramer]".    Because the role name will vary, you'd have to have different version of this expression for every movie.  With mine, one search for "Meryl Streep" would work for any movie, but you could be more restrictive if you wanted.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #111 on: April 29, 2020, 02:31:01 pm »

IsEqual(Moe;Larry and Curly;John, John;Moe, 11)        => true because both John and Moe are in the first list

You're in search all mode here, so I'm returning a false.  It would only be true if you added "Larry and Curly".

Otherwise everything lined up.
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #112 on: April 29, 2020, 02:36:18 pm »

ALL: Given a list A and a list B, IsEqual(A,B,9) returns TRUE if ALL elements of list B are present in list A, regardless of ordering of both lists
ANY: Given a list A and a list B, IsEqual(A,B,11) returns TRUE if AT LEAST ONE element of list B is present in list A

Except this formal description is not what Matt's example show.  What Matt is doing is shown below. Note the difference:
ALL: Given a list A and a list B, IsEqual(A,B,9) returns TRUE if EACH AND EVERY element of list B is present in list A as a whole element, regardless of ordering of both lists
ANY: Given a list A and a list B, IsEqual(A,B,11) returns TRUE if AT LEAST ONE element of list B is present in list A as a whole element

Lists are just strings, with special importance given to a delimiter character.

"Curly" is present in "Moe Larry and Curly", and it is also present in "Moe;Larry;Curly"

Your definition, and what I was thinking, would match against the first  and second.  Matt's ONLY matches against the second, because it is only looking at whole elements.  That is a crucial difference, and a limitation.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Expression functions [HELP WANTED]
« Reply #113 on: April 29, 2020, 02:41:32 pm »

You're in search all mode here, so I'm returning a false.  It would only be true if you added "Larry and Curly".

Otherwise everything lined up.

Hmm, ok. That's a pure Intersect then, only true if both lists have same content regardless or sort order. I think the variant I mentioned would also be useful.

And Wer's variants can also be useful... so, more modes? :)

EDIT: With so many variants, perhaps it would be better to put them in a separate ListEquals() function with different modes.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #114 on: April 29, 2020, 02:44:49 pm »

Hmm, ok. That's a pure Intersect then, only true if both lists have same content regardless or sort order. I think the variant I mentioned would also be useful.

And Wer's variants can also be useful... so, more modes? :)

EDIT: With so many variants, perhaps it would be better to put them in a separate ListEquals() function with different modes.

I like to make as little work for Matt as possible.

We don't need additional modes, it would just need to work like my suggestion.  Not because I'm being a jerk, but because my method can produce EITHER result, based on how you structure the expression.  The other way only works one way.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Expression functions [HELP WANTED]
« Reply #115 on: April 29, 2020, 02:48:20 pm »

No, the strict modes are needed, a simple "contains" is not always desired.
In some cases, you need exact matches to prevent "John" matching "Johnson"... (ie, a substring inadvertently matching another longer string)

edit: IsEqual(Moe/, Larry and Curly, /;Curly/;, 11) = 0
This is award and it implies the list needs to be manipulated, adding the ';' to each element before calling IsEqual.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #116 on: April 29, 2020, 02:51:52 pm »

The reason I'm digging into this is because right before this latest idea was posted, I was thinking about asking the question of would it be possible to support booleans in IsEqual and IfCase. We can insert math() for this but it's cumbersome.

In other words IsEqual(Dick and Jane went to town with Mary, Bob | Mary, 7) = 1

We could get a lot of mileage out of that.  If these new IsEqual modes were following the model I described, it would be basically the same thing, albeit with just AND and OR.  But matching against only whole elements is very restrictive.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #117 on: April 29, 2020, 02:58:16 pm »

No, the strict modes are needed, a simple "contains" is not always desired.
In some cases, you need exact matches to prevent "John" matching "Johnson"... (ie, a substring inadvertently matching another longer string)

edit: IsEqual(Moe/, Larry and Curly, /;Curly/;, 11) = 0
This is award and it implies the list needs to be manipulated, adding the ';' to each element before calling IsEqual.

That's just example syntax; it's irrelevant because MC knows how (or if) the first list is delimited.  There just needs to be some way to signal whole element. You could use ^Curly^ or whatever you want.

Perhaps the best solution would be to have some explicit "whole elements only" flag for the expression.  Text searches do this, with a "whole word only" option.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #118 on: April 29, 2020, 03:04:39 pm »

I just changed it to look at substring matching.  So "Larry" will now match "Larry and Curly".

I didn't add modes for it because it seemed a little overwhelming!
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #119 on: April 29, 2020, 03:09:36 pm »

Yeah it can get complicated.  That's what I was wondering about the booleans.  Do you think booleans would be too complicated?

Also, did you add it to IfCase?  Anything added to IsEqual also has to be added to IfCase.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #120 on: April 29, 2020, 03:24:52 pm »

Yeah it can get complicated.  That's what I was wondering about the booleans.  Do you think booleans would be too complicated?

Also, did you add it to IfCase?  Anything added to IsEqual also has to be added to IfCase.

I made IfCase and IsEqual share all their compare functions and building of the rules.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #121 on: April 29, 2020, 03:31:23 pm »

I just added more modes:
NEW: Added modes 13 through 16 to IsEqual to do full string matching (instead of partial).

Hopefully everybody is happy now (except me!).
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #122 on: April 29, 2020, 03:55:23 pm »

Thanks Matt.

Do you want the next idea to be really easy, or an even bigger challenge?  :P
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #123 on: April 29, 2020, 08:32:59 pm »

Were you still going to do GroupCountQuery to go with GroupSummaryQuery?

It would enable us to do things like:

"You have math(GroupCountQuery(Director,Name,1)- 1) other films by [Director] in your library."
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #124 on: April 30, 2020, 08:43:44 am »

Were you still going to do GroupCountQuery to go with GroupSummaryQuery?

It wasn't on my radar yet, but keep me on my toes!

Could you provide a little more information on the parameters and some examples?

Thanks.
Logged
Matt Ashland, JRiver Media Center

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Expression functions [HELP WANTED]
« Reply #125 on: April 30, 2020, 09:56:28 am »

Matt, what about some additional HTML rendering tags, is that on the radar?
A few useful ones would be < hr>, < center>, < right>, and < Table> or some other equivalent way of creating columns and do horizontal alignment.

I suppose switching to a full HTML rendering engine is out of the question due to opening up too many ways to mess with it.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10925
Re: Expression functions [HELP WANTED]
« Reply #126 on: April 30, 2020, 09:59:44 am »

table is probably a step too far. We may be able to investigate horizontal alignment, and maybe < hr >, but no guarantees on horizontal alignment, as the layout engine does not necessarily always know the exact width of the window its designed to render onto.
Logged
~ nevcairiel
~ Author of LAV Filters

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #127 on: April 30, 2020, 01:22:58 pm »

Understood about the difficulties of HTML rendering and tables.

One problem we face in theater view constantly is layout related, just getting things to fit.

What about as a starting point, just the ability to fit a string of text to one line?

<fit>This is quite a bit of text about [Director], shown here <img src="tooltip:image"> with an image.< br><//fit>

Anything within the fit tag would be shrunk uniformly as needed so it did not exceed the width of the current text line (no wrap).  If it's shorter than the line, no adjustment.  When fields and images are inserted inline, they have differing widths, and the line ending up too long so that it wraps really throws off formatting.

Is that doable?  It would help a lot. 
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #128 on: April 30, 2020, 03:06:58 pm »

It wasn't on my radar yet, but keep me on my toes!

Could you provide a little more information on the parameters and some examples?

Thanks.

Certainly, I'd be glad to.

GroupCountQuery would perform the same function as GroupCount, but in the same abstracted manner as GroupSummaryQuery.

Now currently GroupCount counts the number of unique values of a field for the current context.   If you're looking at an album, GroupCount(Name) counts the number of different Names for all the members of that album.

GroupCountQuery is related, but slightly abstracted. Instead of counting what you're looking at, it counts things related to what you're looking at.

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.

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.

The functionality can be extended if the first field can be combined like a string:
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.

Thanks,

-Will


Logged

seantrow

  • Recent member
  • *
  • Posts: 15
Re: Expression functions [HELP WANTED]
« Reply #129 on: April 30, 2020, 10:23:03 pm »

Is there a function to return the Nth value from a list (basically an indexer)?  This seems like a basic thing but I couldn't find one.

Thanks,
Sean
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #130 on: April 30, 2020, 10:35:10 pm »

Sean,

Yes.  ListItem(list, position, delimiter)   Google "jriver expression language" for more.

But please start a new thread for future how-do-I questions.  This is not a thread for questions, we're developing new extensions to the expression language here.  Thanks.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #131 on: May 01, 2020, 08:02:23 am »

Coming next build:
NEW: Added a GroupCountQuery(...) expression function to group files by a field, then count another field.

I enter:
GroupCountQuery(Genre, Album)

And I get a count of the number of albums in each genre.  It's not the fastest expression, so use it sparingly.

Thanks for the suggestion.
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #132 on: May 01, 2020, 12:41:00 pm »

Thanks!
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #133 on: May 03, 2020, 12:15:58 pm »

ListRemove(list, value, mode) default mode 0=index, 1=value

Remove by index:
ListRemove(a;b;c,1,0) ==> a;c

Remove by value:
ListRemove(a;b;c,b,1) ==> a;c
Logged

janpeeters

  • Junior Woodchuck
  • **
  • Posts: 53
Re: Expression functions [HELP WANTED]
« Reply #134 on: May 04, 2020, 07:30:58 am »

I would love a Samplerate field without the 'Khz'.
I created a 'bitdepth | samplerate' column to save space. But the 'Khz' is superfluous for me and takes space ;-).

Sidenote:
Maybe there's a truncate function to remove x characters from the end of a field but that exceeds my knowledge.
If anyone knows I would love to hear it.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #135 on: May 04, 2020, 07:36:04 am »

I would love a Samplerate field without the 'Khz'.
I created a 'bitdepth | samplerate' column to save space. But the 'Khz' is superfluous for me and takes space ;-).

Sidenote:
Maybe there's a truncate function to remove x characters from the end of a field but that exceeds my knowledge.
If anyone knows I would love to hear it.
You can trim " kHz" out by using RemoveRight (number 4 indicating how many characters to trim in below example)
Code: [Select]
RemoveRight([Sample Rate],4)
Logged

janpeeters

  • Junior Woodchuck
  • **
  • Posts: 53
Re: Expression functions [HELP WANTED]
« Reply #136 on: May 04, 2020, 08:00:15 am »

You can trim " kHz" out by using RemoveRight (number 4 indicating how many characters to trim in below example)
Code: [Select]
RemoveRight([Sample Rate],4)

Thanks for your swift help @lepa. Really appreciated.
Can I ask you one more thing. Is there also a function the round Samplerate in this example. I would rather see "16 | 44" then "16 | 44.1"

Thanks, Jan
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #137 on: May 04, 2020, 08:15:45 am »

If Sample Rate is always normally displayed with one decimal then you'd just increase trim amount from 4 to 6
RemoveRight([Sample Rate],6)

remove 6 characters starting at right from "44.1 kHz" ==> 44.1 kHz
Logged

janpeeters

  • Junior Woodchuck
  • **
  • Posts: 53
Re: Expression functions [HELP WANTED]
« Reply #138 on: May 04, 2020, 08:16:52 am »

If Sample Rate is always normally displayed with one decimal then you'd just increase trim amount from 4 to 6
RemoveRight([Sample Rate],6)

Of course hahaha, You have a better brain for this then I have. Thanks!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #139 on: May 04, 2020, 02:49:29 pm »

You can also use the new Number(...) function.  Here's an example:
FormatNumber(Number([In Sample Rate]), 0)
Logged
Matt Ashland, JRiver Media Center

janpeeters

  • Junior Woodchuck
  • **
  • Posts: 53
Re: Expression functions [HELP WANTED]
« Reply #140 on: May 04, 2020, 02:54:50 pm »

You can also use the new Number(...) function.  Here's an example:
FormatNumber(Number([In Sample Rate]), 0)

Thanks Matt, is there a place where I can read upon this a bit more?
I'm sure that what you write will work but I don't understand a bit of it ;-) And I'd love to understand this better. 
Logged

seantrow

  • Recent member
  • *
  • Posts: 15
Re: Expression functions [HELP WANTED]
« Reply #141 on: May 06, 2020, 04:15:30 pm »

This isn't quite a function expression language request, but one thing I would love is some kind of experimental function evaluator window to test/debug things.

Right now for instance, I might want to add a new computed field to my database.  I have to go through a pretty awkward loop of editing an expression in an external text editor (it might get pretty complicated), bringing up the library schema editor, paste in the new expression into the little text field there, then exit back out of all the dialogs and see what the result is.  (Usually, it's "oh xxx, I had a syntax error"...) It would be save a lot of time if I could change the expression and see the result in a single dialog.

(I realize that expressions can occur in various contexts, so this might be more complicated than it first seems.)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #142 on: May 06, 2020, 04:17:14 pm »

This isn't quite a function expression language request, but one thing I would love is some kind of experimental function evaluator window to test/debug things.

Right now for instance, I might want to add a new computed field to my database.  I have to go through a pretty awkward loop of editing an expression in an external text editor (it might get pretty complicated), bringing up the library schema editor, paste in the new expression into the little text field there, then exit back out of all the dialogs and see what the result is.  (Usually, it's "oh xxx, I had a syntax error"...) It would be save a lot of time if I could change the expression and see the result in a single dialog.

(I realize that expressions can occur in various contexts, so this might be more complicated than it first seems.)

I just add an expression column and I think it works pretty well.
Logged
Matt Ashland, JRiver Media Center

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #143 on: May 06, 2020, 04:23:38 pm »

That's what I do too.

It would be nice if the built in expression editors could link to use Notepad++ as an external editor so that syntax highlighting, autocomplete, and lexical hints could be used.  The built-in editor his hints and the "insert function" menu, but not much else.  So currently the process is just cut-and-paste back and forth.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #144 on: May 09, 2020, 02:13:25 am »

RegexReplace(String, Search Regex, Replace Regex, mode)

https://yabb.jriver.com/interact/index.php/topic,120778.msg835176.html#msg835176
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #145 on: May 09, 2020, 03:45:18 am »

Yes, that would be useful.  And since you're using the MS regex engine, there could be an option for overlapping matches.

What do you think of linking to NPP as an external editor? Could be with a hotkey, if you don't want to touch the GUI.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #146 on: May 15, 2020, 03:04:52 am »

Can Lepa's RegexReplace function happen Matt, or is that a no go?
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression functions [HELP WANTED]
« Reply #147 on: May 15, 2020, 06:21:25 pm »

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression functions [HELP WANTED]
« Reply #148 on: May 15, 2020, 11:52:03 pm »

Just mentioning here that I've found GroupCountQuery is not always returning correct results, and it's useless in the file info panel because it always returns 1 there.  I've reported this in the 26.0.80 release thread.   I'm hoping for a fix as this function is key to getting related information into the file info panel in Theater View.

To reiterate the issue here, in case people are not looking at the other thread:

I have 6 movies directed by John Houston...

If I use GroupCountQuery(Director,Name) in an expression column, it returns 6, which is correct.

If I use it the File Info Panel in Theater View, it always returns 1.  That's wrong; it should always return 6, regardless of where it's used.

For a bit more info, it seems to be returning the number of matches in the current view. (and the current view for the file info panel is always 1 file).  For example, if I use a Panes view and filter by Studio, the same function stops returning 6 and instead returns 2, which is the number of movies John Huston directed with the currently filtered Studio in the view.  That's not correct.  It should only return 2 if the expression was GroupCountQuery(Director;Studio, Name).

GroupCountQuery(Director,Name) should return the same result globally, no matter which of that Director's movies you look at and no matter the view.  That's what we discussed.  A function that always returns 1 in the file info panel has no utility at all.

GroupSummaryQuery has the same problem: it seems to be context sensitive. That means it can't be used in Theater View either.

It also seems upon further testing that there is no ability with GroupSummaryQuery to join fields in the search, as GroupCountQuery has.

GroupSummaryQuery(Artist,Duration) should return the total duration of all tracks by that artist. It does in an expression column, but not in theater view.

GroupSummaryQuery(Artist;Composer,Duration) should return the total duration of all tracks with the same artist and composer. But this functionality is missing.

I regret not being able to thoroughly test these earlier, but some of this wasn't pushed out to the regular in-app-update channel until after a multi-week delay, and then the last couple of weeks I have been preoccupied with the Syntax Highlighter. So this is my first attempt to do anything serious with them.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42344
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #149 on: May 18, 2020, 09:36:36 am »

GroupCountQuery was working on the working set of files, but there is no working set in the Theater View info panel.

So I'll try to make the next build just use all the files in the library.

I'm making the change to GroupCount and GroupCountQuery.

Testing appreciated once the build ships.  Thanks.
Logged
Matt Ashland, JRiver Media Center
Pages: 1 2 [3] 4 5 6 7 ... 9   Go Up