INTERACT FORUM

Please login or register.

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

Author Topic: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?  (Read 2135 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608

A while back you gave us both the ability to use the = sign to do inline text manipulation edits, and the wonderful RemoveRight(), RemoveLeft(), and Mid() expressions, and there was much rejoicing and jubilation.  This has allowed our busy MC wielding warriors to make short work of jobs like trimming off useless junk from the beginning and end of our [Name] tags.

However, it wasn't long before those of us doing mass organization found one last hole in the wonderful text trimming scheme... Sometimes, instead of wanting to Remove the text at the beginning or end of a particular tag, I want to remove all of the text in the tag except for a certain number of characters from right-hand side (or the left, though this can be done currently using the Mid() expression).  In other words, I want to trim off junk of an arbitrary length from the leftmost portion of a particular tag (most commonly [Name]), while preserving a fixed number of characters counted from the rightmost side of the string.

This isn't currently possible, unless I'm missing something.

It'd be pretty sweet if there could be an optional third parameter added to the RemoveRight(), RemoveLeft(), and Mid() expressions that would return the inverse of the normal returned value.  So, for example:

RemoveRight(...)
Field: the field to trim
Count: how many characters to trim
Mode: normal=0 or inverse=1 (optional, defaults to normal)

Code: [Select]
Examples:
RemoveRight(abba abc,4) returns abba
RemoveRight(abc abba,4,1) returns abba
Logged
"Some cultures are defined by their relationship to cheese."

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

MusicHawk

  • Citizen of the Universe
  • *****
  • Posts: 796
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #1 on: March 09, 2009, 11:42:20 pm »

I agree with the value of this request, but it's just a start. There are so many ways data might be manipulated -- if we had the functions to do so -- that it makes me wonder how far MC might be evolved in this direction. I'd love to see it go FAAAAR -- Lotus Notes is a good example of a massive collection of string and number manipulation tools, since it's a rich-text "database" system. (In fact, I saw an impressive MC-type music library/player application built with Lotus Notes years ago -- just as a trade show demo of the product's app-development capabilities.) But with the focus on making MC a TV system, maybe extending its "language" isn't a goal.

Perhaps Matt or Jim or someone could one day tell us the vision or plan for providing more functions and expression capabilities, or not, whatever might be the case. Then we'd know whether to pile on the requests, or not. (I'd be happy to paste in some of the key Lotus Notes functions that I wish were in MC, things like searching right and left, frontward or backward, selecting by character count OR by a specified substring, and several more.)

My biggest wish is that a function or expression could be associated with every field (standard and custom) that gets executed when the field value is changed -- essentially a transformation that helps standardize the data every time it is saved. This would allow for such actions as forcing all caps for a field, or removing leading/trailing spaces, or even pushing a value into another field based on the changed field. Again, Lotus Notes is my model though many programmable systems allow this.

For instance, I find typing or pasting errors that resulted in Name or other field values with leading or dangling spaces, inadvertent but a problem for sorting and matching. If an an expression could be associated with the field to execute the Remove functions, the data could always be trimmed as desired, even after sloppy typing.

Or... If providing full expression execution per field is beyond the scope of MC, perhaps allow certain common actions to be controlled per field via checkboxes, actions like trimming leading/trailing spaces, forcing all-caps or lowercase or proper case, etc. It would be important that such a feature be available in both standard and custom fields.
Logged
Managing my media with JRiver since Media Jukebox 8 (maybe earlier), currently use Media Center for Audio/Music and Photos/Videos.
My career in media spans Radio, TV, Print, Photography, Music, Film, Online, Live, Advertising, as producer, director, writer, performer, editor, engineer, executive, owner. An exhausting but amazing ride.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42388
  • Shoes gone again!
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #2 on: March 10, 2009, 03:52:32 pm »

Seems like Length(...), Left(...), and Right(...) would be the needed functions.

If you do the wiki, we'll do the coding.  Deal?
Logged
Matt Ashland, JRiver Media Center

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #3 on: March 10, 2009, 04:09:58 pm »

Seems like Length(...), Left(...), and Right(...) would be the needed functions.

If you do the wiki, we'll do the coding.  Deal?

Yep.  Those would be perfect.  I suggested the "inverse" idea because I thought it'd be easier to add the function to an existing one, rather than create new functions.  Left(), Right(), and Len() would be ideal!

Deal!
Logged
"Some cultures are defined by their relationship to cheese."

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

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #4 on: March 10, 2009, 04:17:40 pm »

After that, about the only String manipulation functions we're missing are the equivalents of InStr() and InStrRev().  These can mostly be accomplished on the fly using the regular searching mechanism.  Otherwise, I never have cause to use them, at least for quick [Name] manipulation.  Perhaps they'd be useful in complex searches though...
Logged
"Some cultures are defined by their relationship to cheese."

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

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42388
  • Shoes gone again!
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #5 on: March 10, 2009, 05:33:38 pm »

We also added a Math(...) function to a coming build for evaluating formulas.

You can do things like this to remove the track # from the front of the name, regardless of the length:
=RemoveLeft([Name], Math(Length([track #]) + 2))

And we don't want to know the tangent of the square root of the duration of a song, but we're pretty sure some of our users do.
Logged
Matt Ashland, JRiver Media Center

gappie

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4580
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #6 on: March 10, 2009, 05:56:44 pm »

And we don't want to know the tangent of the square root of the duration of a song, but we're pretty sure some of our users do.

i was about to do that and put it up against the Fibonacci numbers to make some smartlists for when my karma level is low... but when mc can do that it self that is great!!!
Logged

Lasse_Lus

  • Citizen of the Universe
  • *****
  • Posts: 999
Re: RemoveLeft() and RemoveRight() Expressions, Can We Get The Inverse?
« Reply #7 on: March 10, 2009, 06:02:22 pm »

We also added a Math(...) function

wow, looking really forward to to do some calculations  :D (/*-+)
Logged
MT5FR
Pages: [1]   Go Up