INTERACT FORUM

Please login or register.

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

Author Topic: Feature request, new list manipulation function  (Read 1176 times)

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Feature request, new list manipulation function
« on: June 26, 2019, 10:14:37 am »

I'd like a way to return X number of items from a list type library field, call it something like ListLimit()

Description: ListLimit(list, number to output)

The ListLimit() function returns a defined number of items that exist in a list delimited by delimiter.


Example: ListLimit([Actors], 4)
Returns the first four values of the Actors field

   

Or something along those lines.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42381
  • Shoes gone again!
Re: Feature request, new list manipulation function
« Reply #1 on: June 26, 2019, 10:25:04 am »

It's a good idea.  I'll add it to the next build.
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new list manipulation function
« Reply #2 on: June 26, 2019, 10:32:46 am »

Awesome, thanks Matt!
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new list manipulation function
« Reply #3 on: June 26, 2019, 05:18:11 pm »

Matt, maybe this could be fleshed out a bit more?  Something along the lines of

ListLimit(list, offset, length, delimiter)

ListLimit([Actors], 0, 5)

Returns a list of 5 actors starting at index 0.

Additionally, use negative offsets to mean "from the end".

ListLimit([Actors], -4)

Returns the last 4 actors, or

   ListLimit([Actors], -5, -3)

Returns the first 3 actors of the last 5 actors in the list.

Just a thought, thanks again.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42381
  • Shoes gone again!
Re: Feature request, new list manipulation function
« Reply #4 on: June 27, 2019, 08:19:45 am »

I'll integrate some of your idea in the next build:
Changed: Made the ListLimit MCWS function take an optional third parameter for the index to start at.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42381
  • Shoes gone again!
Re: Feature request, new list manipulation function
« Reply #5 on: June 27, 2019, 11:14:31 am »

Doing another one now:
Changed: Made passing a negative number into ListLimit will grab that many from the end of the list.

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

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42381
  • Shoes gone again!
Re: Feature request, new list manipulation function
« Reply #6 on: June 28, 2019, 02:26:42 pm »

Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new list manipulation function
« Reply #7 on: June 28, 2019, 03:14:04 pm »

Thank you!
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new list manipulation function
« Reply #8 on: July 01, 2019, 11:33:36 am »

Matt, this is working great but I have an issue.

Is there any way, when using ListLimit() in a custom library field to allow the field to be a list type field, right now it defaults to a string type. 

As an example, I have a field called [TMDB Actors] which is a list type field, it gets populated using MrC's MCUtils script which pulls 20 actors from TMDB.  I created a new expression field called [TMDB Actors Short] and I am using ListLimit([TMDB Actors], 5, 0) to cull that down to 5 actors.   

If I use [TMDB Actors] in Theater View it returns one actor per line which is how I want things to be handled.
If I use [TMDB Actors Short] it returns all 5 actors in one line (well, it wraps if it runs out of room, but still)

Hopefully that makes sense.

Thanks!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42381
  • Shoes gone again!
Re: Feature request, new list manipulation function
« Reply #9 on: July 01, 2019, 11:53:23 am »

I can help with that!

Just add this to your expression for the field and it will become a list and after the formatting in Theater View should use newlines just like you were hoping:
Code: [Select]
&DataType=[list]
Logged
Matt Ashland, JRiver Media Center

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Feature request, new list manipulation function
« Reply #10 on: July 01, 2019, 12:01:39 pm »

Ah, perfect.  Thank you! 
Logged
Pages: [1]   Go Up