INTERACT FORUM

Please login or register.

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

Author Topic: Expression Revision Question  (Read 768 times)

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Expression Revision Question
« on: July 14, 2022, 08:57:33 am »

I have a calculated field, [Composer Name Swap], for some of my views that switches names around, e.g., "Brahms, Johannes" instead of "Johannes Brahms." Someone (ferday? blgentry?) created it for me on Interact a few years ago. The problem is with compositions which have multiple composers listed. How do I avoid "Heiniger, Enno Poppe;Wolfgang" and instead get "Heiniger, Wolfgang; Enno Poppe?" 

Here's the expression:

Code: [Select]
if(!regex([Composer], /#^([^,]+)\s+([^,]*?)$#/),
   [Composer],
   regex(listclean([Composer], 2, / ),
         /#^(?:(I+|[JS]r\.?)\s+)?([^ ]+)(.*)$#/, -1)[R2]/,/ listclean([R3], 2, / )[R1]
)

I tried playing around with it in Zelda, but I'll confess that the syntax makes my head hurt. I'm guessing the issue is in the listclean section? Thanks for any help!
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41936
  • Shoes gone again!
Re: Expression Revision Question
« Reply #1 on: July 14, 2022, 09:09:23 am »

Maybe look at the Swap(...) and Unswap(...) expressions.
Logged
Matt Ashland, JRiver Media Center

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Revision Question
« Reply #2 on: July 14, 2022, 09:21:27 am »

Yes, I had initially tried those way back in MC version 21 or 22, but they didn't account for composers with three parts to their names, e.g., "Ludwig van Beethoven" or "Pyotr Ilyich Tchaikovsky"--hence the more complex version. But looks like that works now, via my test in Zelda.

One further question, however: for multiple composers, I get "Poppe, Enno;Heiniger, Wolfgang." How would I get it to display either

"Poppe, Enno; Wolfgang Heiniger"

or, more simply

"Poppe, Enno; Heiniger, Wolfgang"

with an extra space after the semicolon in the latter? I'd prefer the first version but would settle for the second.

Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41936
  • Shoes gone again!
Re: Expression Revision Question
« Reply #3 on: July 14, 2022, 09:25:55 am »

We no longer put a space after the separator.
Logged
Matt Ashland, JRiver Media Center

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Revision Question
« Reply #4 on: July 14, 2022, 09:40:02 am »

I understand not having the space after the semicolon in expressions themselves, but is there a way to get a space in there simply for viewing's sake? Or to do the first version, experssion-wise?

Another issue with simply using Swap(): I get this at the top of S in my view:

"Loussier, Jacques;Satie, Erik"

How would I get "Satie, Erik;Loussier, Jacques" under S and the former under L?

Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41936
  • Shoes gone again!
Re: Expression Revision Question
« Reply #5 on: July 14, 2022, 10:28:23 am »

A couple years back we made this change:
Changed: Display of list fields stores ";" for the delimiter but now displays "; " for the delimiter in file lists.

So the display should have a space, it's just not stored with a space.

Maybe if you're looking at the field in some way other than a file list showing a data type list field it won't work?

If you've got an expression column, try adding &DataType=List.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41936
  • Shoes gone again!
Re: Expression Revision Question
« Reply #6 on: July 14, 2022, 10:38:56 am »

I just found that expressions don't trigger it even with the list type.

Next build:
Changed: Only fields would get ";" replaced with "; " at display time.  Now list style expressions are evaluated as well.
Logged
Matt Ashland, JRiver Media Center

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1965
Re: Expression Revision Question
« Reply #7 on: July 14, 2022, 10:41:22 am »

Code: [Select]
ListClean(ListMix(if(!Regex([L1], /#^([^,]+)\s+([^,]*?)$#/),[L1],Regex(ListClean([L1], 2, / ),/#^(?:(I+|[JS]r\.?)\s+)?([^ ]+)(.*)$#/, -1)[R2]/,/ ListClean([R3], 2, / )[R1]),,[Composer]),4)Would this work? If it does we can also insert space after ; if needed

not sure if formatting works with listmix but below same but with some formatting to help readibility
Code: [Select]
ListClean(
    ListMix(
        if(!Regex([L1], /#^([^,]+)\s+([^,]*?)$#/),
            [L1],
            Regex(ListClean([L1], 2, / ),/#^(?:(I+|[JS]r\.?)\s+)?([^ ]+)(.*)$#/, -1)[R2]/,/ ListClean([R3], 2, / )[R1]
        )
        ,,[Composer]
    )
    ,4
)

Quote
composer:
Ludwig van Beethoven;Pyotr Ilyich Tchaikovsky

expression output:
Beethoven, Ludwig van ;Tchaikovsky, Pyotr Ilyich

composer:
Ludwig van Beethoven

expression output:
Beethoven, Ludwig van

composer:
Erik Satie

expression output:
Satie, Erik
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Revision Question
« Reply #8 on: July 14, 2022, 01:06:06 pm »

Yes, that does work. Thanks!

Let me ask, though: is there a quick way to get it to put subsequent composers as first name last name, e.g., Brahms, Johannes;Ludwig van Beethoven;Pyotr Ilych Tchaikovsky? Or is that too much of a pain?

Thanks again!
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Revision Question
« Reply #9 on: July 14, 2022, 01:54:41 pm »

It does still have the problem with multiple composers in alphabetical order within a list, however (see what I said about Satie and Larousse above and in the image below).

Logged
Pages: [1]   Go Up