INTERACT FORUM

Please login or register.

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

Author Topic: Simple expression help...  (Read 2421 times)

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Simple expression help...
« on: April 08, 2020, 10:29:44 am »

Greatday,

Trying to set up a very simple Ifisequal expression... But can't figure thisone out :-(

It seems i can't get a difference made into the expression, where 10 should be differently evaluated as 1.
Each time "10" is evaluated it outputs the field x instead of y.

Code: [Select]
if(isequal([field],1,8),[x],if(isequal([field],10,8),[y],[z]))
I've tried mode 8,1 and 2.

What's the trick to avoid "10" is seen as a "1"

Thanks for your help !
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8955
Re: Simple expression help...
« Reply #1 on: April 08, 2020, 11:39:41 am »

Difficult to know what you're doing from the information provided, but, to get you started....

Mode "8" is a substring compare, and you start with "1", as "1" will evaluate to x for any field that contains "10", the expression is complete and therefore, the test for a substring match on "10" is never carried out.

Do you need a substring compare? if [field] only contains numbers, then consider using the available numeric compare modes 2 to 6. If not, try switching the compares around, ie, test for 10 first, then 1.

marko

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #2 on: April 09, 2020, 03:22:21 am »

GREAT !
Marko thanks, reversing, by putting the 10 as first into the expression did the trick !

One more for the road; how to we clear and 'old' and unused field ?

I've got one fieldnaming which I'll like to reuse.
The old field was deleted from the field manager a while ago, but when trying to remake a field with this naming again it creates a (1).

FYI saving in tags isn't ticked on this field.

Thanks Marko for your input sir.

Stay save.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #3 on: April 09, 2020, 03:42:11 am »

One more for the road; how to we clear and 'old' and unused field ?

I've got one fieldnaming which I'll like to reuse.
The old field was deleted from the field manager a while ago, but when trying to remake a field with this naming a
Maybe it's still there but hidden. Change "Show all fields" to "Show hidden fields" in Manage Library fields and see if the field still exists
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #4 on: April 09, 2020, 07:33:20 am »

Thanks Lepa !

I didn't knew about the fildering on hidden fields till now :-)
And yes i found it, the field was hidden AND renamed to another fieldname aswell.

Stay save and take care to all of you !
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #5 on: April 13, 2020, 05:14:13 am »

Great day all of you,

Hoping you're all safe and well.

I've got another basic expression which I'm not able to figure out:

I'll need to filter out some of useless characters within an existing MC field.
Only numbers should be left (copied) over.

As the length of the data could be variable i can't use the removeleft/right expression.
But what's making it more complex is not only there are letters in the existing data but the complete string is within [] brackets.

Short which expression to filter other stuff out and only keeping numbers ?
I'm guessing I'll have to add a new field and link the existing field in within the expression.

Another thanks and take care !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #6 on: April 13, 2020, 05:26:19 am »

You could experiment with Number() function. Though I guess it only takes first encountered number/period/comma character but it might be enough for you.
Code: [Select]
Number(This is string.and has number 15 in it.)Above will only get you that first period...

This will work though
Code: [Select]
Number(This is string and has number 15 in it)
This would take out [] before applying number function
Code: [Select]
Number(Replace(Replace([Field],/],_),/[,_))or this would probably work also if brackets are first and last characters
Code: [Select]
Number(RemoveLeft(RemoveRight([Field],1),1))
If you are feeling adventurous you can surely achieve what you want with RegEx() function...
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #7 on: April 13, 2020, 01:10:23 pm »

Many thanks Lepa !

Your last option did the trick perfectly sir.

Another thanks,

Take care.
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #8 on: April 19, 2020, 08:22:06 am »

Great day to all of you,
Hoping you're all safe and well,

I've got another puzzle which I'm trying to solve since some hours,
Several attempts, forum searches, incl the below, but i can't get a good result :-(

Code: [Select]
if(isequal(!isempty([AMG Artist Members]):!isempty([AMG Artist Died]), 1:1), both not empty, both empty)
Let me explain some more about the goal of the above,

I'm setting up a new Theater View template for my albums.
Within the small (selected) window I'm adding some details concerning the selected Artist:
-[AMG Artist Members]
-[AMG Artist Born]
-[AMG Artist Died]

But as not all albums have those details (AllMusic and Discogs scrapes) I'm trying to find some expressions to line the data up.
I'm trying to avoid empty lines and/or losing space and so expressions within the same line.

Actually if x,y,z are available = 3 lines of data.
If only x and z are available = only 2 lines.
Or if p.e. only z is available = 1 line.

Where I'm placing the data from [AMG Artist Members] field as italic,
Data from both other fields (born & died) as standard, but with "Artist born:" or "Artist died:" as pretext.

For starters i came up with the following:
Code: [Select]
<font size="80" color="#9496a3">If(IsEmpty([AMG Artist Members]),Artist born: [AMG Artist Born],<i>[AMG Artist Members])<//i>
<font color="#9496a3">If(IsEmpty([AMG Artist Members],[AMG Artist Born]),<font size="80" color="#9496a3">Artist died: [AMG Artist Died],Artist born: [AMG Artist Born])<//font>

This gave me a good solution for the first 2 lines, but the got stuck :-)
Fonts can also be some struggle, sometimes the font wouldn't be respected and I'll have to repeat the font.

I know it's pretty easy stuff to some of you but at this point I'm a bit lost on this expression :-)

Thanks for any clue or pointers into the right direction.

Take care and stay safe !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #9 on: April 19, 2020, 09:11:53 am »

Not sure if I understood correctly what you are trying to accomplish in detail but if you just want to output 1-3 lines of metadata depending on if tag has some value you could just print every tag under not empty expression and add linefeed
 after prinout.

Code: [Select]
If(!IsEmpty([AMG Artist Members]),Artist members: [AMG Artist Members]<br>,)If(!IsEmpty([AMG Artist Born]),Artist born: [AMG Artist Born]<br>,)If(!IsEmpty([AMG Artist Died]),Artist died: [AMG Artist Died]<br>,)If you want to format text with html tags make sure, that you open and close tag inside same context so that opened tag will surely get closed
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #10 on: April 19, 2020, 11:12:39 am »

Arh, such a simple solution :-):-):-)

Yes thanks Lepa, you've captured my puzzle perfectly,
Your expression did the trick :-)

Another thanks and stay safe !
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #11 on: May 01, 2020, 04:22:47 am »

Greatday to all of you,
Hoping you're all safe and well,

I might have another expression question,

I'm again working onto the Theater View templates, the Audio template to be more specific:

With the help of you I've managed to get the bandmembers of the album to show and the born and died details aswell.

Additionally I'm trying to add a field to display all alternative albums by the same [Album Artist (auto)].
I'm guessing my challenge is skipping the fact I'm already within an specific album, so the listitem only gives me the actual album instead of all albums using the same [Album Artist (auto)], right ?

P.e. I'm in Theater View and have the album "Ten" selected, looking at the tracknumbers, details as label and composer, the ratings, the bandmembers but also like to see a list of alternative works by Pearl Jam.

Any pointers ?

Another thanks and stay safe !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #12 on: May 01, 2020, 11:56:31 am »

Not so simple expression this.

Haven't check if this can be done with new expressions Matt has been busy lately but I created something with variables...

Following will save artist name into first item of the list and after that all the albums which was found for that artist. Could slow down your view loading so be warned... Artist could of course also be replaced with [Album Artist (auto)]

To the viev file rules as custom rules:
Code: [Select]
[=Save([Artist],vAlbumsByArtist[Artist],1)1]=1
Code: [Select]
[=If(IsEqual(ListItem(Load(vAlbumsByArtist[Artist]),0),[Artist]),If(IsEmpty(ListFind(Load(vAlbumsByArtist[Artist]),[Album])),SaveAdd(vAlbumsByArtist[Artist],[Album],1),),)1]=1
To load variable (You need to remove or not show that first item, which contains artist name):
Code: [Select]
Load(vAlbumsByArtist[Artist])
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #13 on: May 01, 2020, 12:47:36 pm »

Greatday Lepa !

Whooh, that's a complicated one :-)

Thanks for your feedback and help, but I'm lost within the instructions unfortunately.
Would you be willing to add some steps ?

I've read your instructions a couple of times, and I'm thinking, if you're afraid this could slow down my view, would it be possible if we do something on tags ?
Writting a new field as semicolom list with the albumnames inside ? Linked to the Album Artist (auto) field ?
So i can just point out to this new field to list to respective albums ?

Another thanks sir !
Stay safe !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #14 on: May 01, 2020, 01:14:35 pm »

I'll explain in more detail later if no one hasn't already. Need a little brain break just now. Bump in couple of days if nothing has happened.
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #15 on: May 02, 2020, 04:04:16 am »

Greatday all, anyone willing to assist me on this request ?

Or shining me a light how to get all [Album Artist (auto)] specific albums into a new field p.e. 'Artist Works' ?
Having this info within a tag would make is fast and easy to display the details within a Theater View template.

Thanks to all and Lepa for the first, but a bit complex to me, clue :-)

Take care and stay safe !
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #16 on: May 03, 2020, 11:08:02 am »

Greatday Lepa, hoping your brain did recovered a bit from the latest challenges :-)

Once you're fine, and find some spare time, would you be able to assist me some more onto this "Artist Works" field or Theater View rule I'm trying to add.
I've tried to add those customer rules into my Theater View template, but I'm sure i do miss something to actually load or have the album titles to pop-up as alternative works to the selected one.
Not sure if i need some custom MC field to achieve such a list, like [Artist Works].

Thanks in advance sir !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #17 on: May 03, 2020, 12:02:17 pm »

It might be easiest to do smartlist which does the calculation. So create new smartlist (Use import/export to import below code). I have created a group first where I would enter all my calculation smartlist. Pics 1 and 2

Code: (PIC2 SMARTLIST RULE) [Select]
[Media Type]=[Audio] [Media Sub Type]=[] -[Album Artist (auto)]=[/(Multiple Artists/)] [=Save([Artist],vAlbumsByArtist[Album Artist (auto)],1)1]=1 [=If(IsEqual(ListItem(Load(vAlbumsByArtist[Album Artist (auto)]),0),[Artist]),If(!ListContains(Load(vAlbumsByArtist[Album Artist (auto)]),[Album],2),SaveAdd(vAlbumsByArtist[Album Artist (auto)],[Album],1),),)1]=1
Pic 3 Add smartlist rule into theaterview view rule where you need these results so it will be calculated every time you enter this view and get fresh results
Pic 4 Create some placeholder inro your file info panel where your albums are displayed

LOAD examples which can be used in that placeholder (pic4, Album count can also now be counted):

Code: (PIC4: LOAD in TV (Albums separated with enter)) [Select]
Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)),;/ ,<br>)
Code: (PIC4 Alternative: LOAD in TV (Images, you need use your own album art path)) [Select]
<font size="500"><img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] - Replace(Clean(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)),3),;/ ,.jpg">/ <img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] -/ ).jpg"><//font>
Code: (PIC4 Alternative: LOAD in TV (Albun count)) [Select]
ListCount(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)))
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #18 on: May 04, 2020, 03:30:43 am »

Greatday dear Lepa !

Boom ! Got it working, thanks a lot sir !

Looking at the rules and content, the request wasn't a simple one :-)

I've went with the following placeholder to display the alternative albums per Album Artist (auto) and excluding the selected album:
I went with an inline and ; as separator instead of list as the space is rather limited and sometimes there are +15 albums :-)

Code: [Select]
<font size="80" color="#9496a3">Alternative Albums: Replace(Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)),; / ,;), [Album])
Something isn't correct within my adaption, the displayed content is correct and even the active album is excluded, but I'm getting a ; to much, from the album I'm excluding.
I don't see how to correct this, thanks again for your help :-)

And one more (smaller) request, could we sort the results up per year aswell ? So the oldest release first -> newest.

Cool stuff, take care and stay safe !
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #19 on: May 06, 2020, 09:21:04 am »

Hoping you're doing fine Lepa,

One more question :-)
How do i exclude the actual/selected Album from your expression ?
Code: [Select]
<font size="500"><img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] - Replace(Clean(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)),3),;/ ,.jpg">/ <img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] -/ ).jpg"><//font>
The idea is, now I've got this working, is showing all/only alternative works of the selected Album Artist (auto).
As the selected album is already displayed into the view.
I've tried every possible way to insert an extra Replace command within the expression, but can't figure it out.

Thanks again sir !

Take care and stay safe !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #20 on: May 06, 2020, 11:32:15 am »

Code: [Select]
ListClean(Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2));,[Album];,),1)
I don't know how to do sorting with MC's expression language. You could add album date in front of every album in the list and then do ListSort() when displaying list but I don't know regular expression so well that I can tell you how to remove dates before displaying it.

So you'd have:
1995 - Album1;1996 - Album2;1997 - Album3
First date you can trim easily but after that I guess you'd need some regex to remove everything which are inside ";" and " - " and replace it just with ";" to keep list structure. You need to figure it out yourself as I don't have currently have the knowledge to do it
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #21 on: May 06, 2020, 12:55:30 pm »

Many thanks Lepa !

Appreciated sir, the learning curve on this stuff is pretty steep to me  8)

I haven't got the updated expression to work.
I'm no at trying to splice it into pieces so i can understand more about it.
Hopefully i can figure it out :-)

But something I've noticed, even with the original expression, in case an Album is name same like the (Artist and) [Album Artist (auto)] if will be excluded from the result.

So p.e. Pearl Jam has an album named Pearl Jam, then this album will be out of the listing.

Any clue how to correct, as this fact is out of my league :-)

Thanks Lepa for your help sir !

Take care and stay safe.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #22 on: May 06, 2020, 01:13:43 pm »

But something I've noticed, even with the original expression, in case an Album is name same like the (Artist and) [Album Artist (auto)] if will be excluded from the result.

So p.e. Pearl Jam has an album named Pearl Jam, then this album will be out of the listing.

Any clue how to correct, as this fact is out of my league :-)
You need more logic in the SAVE rules part for s/t albums.
Something like this maybe. Didn't check if it works as I'm kind of hurry and beat. Idea is to add "ID" postfix to first index which contains the artist name so it is not  caught by ListContains function as s/t album and is added to albumlist. "Pearl JamID" vs "Pearl Jam" (the album)

[=Save([Album Artist (auto)],vAlbumsByArtist[Album Artist (auto)]ID,1)1]=1

[=If(IsEqual(ListItem(RemoveRight(Load(vAlbumsByArtist[Album Artist (auto)]),0),2),[Album Artist (auto)]),If(!ListContains(Load(vAlbumsByArtist[Album Artist (auto)]),[Album],2),SaveAdd(vAlbumsByArtist[Album Artist (auto)],[Album],1),),)1]=1
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #23 on: May 06, 2020, 05:12:16 pm »

Thanks Lepa for the help !
No luck this time I'm afraid. No results showing up, but no expression error at the placeholder neither.
I've tried to break the expression up in order to understand  your work.  But it's rather complex  8)
If you've got some spare time.... could you have another look onto these expressions sir.

Another thanks !
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #24 on: May 07, 2020, 12:53:06 am »

There was couple of misplaced things on above examples...

To save albums into variable field
adds artist+ID to rows variable field e.g. vAlbumsByArtist[Album Artist (auto)] = "Pearl JamID" after this
Code: [Select]
[=Save([Album Artist (auto)]ID,vAlbumsByArtist[Album Artist (auto)],1)1]=1
Add all albums to variable field for the artist in question e.g vAlbumsByArtist[Album Artist (auto)] = "Pearl JamID;Pearl Jam;Ten;"
Code: [Select]
[=If(IsEqual(RemoveRight(ListItem(Load(vAlbumsByArtist[Album Artist (auto)]),0),2),[Album Artist (auto)]),If(!ListContains(Load(vAlbumsByArtist[Album Artist (auto)]),[Album],2),SaveAdd(vAlbumsByArtist[Album Artist (auto)],[Album],1),),)1]=1First part checks that artist is correct and second if adds album into the list, if it is not there yet


to show "other" albums. Removes Artist+ID item and also this rows album. added ";" to the end to make it easier to deal with it.
Code: [Select]
ListClean(Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]);,Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2));,[Album];,),1)
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #25 on: May 07, 2020, 09:04:20 am »

Hi Lepa, great day sir,

Great ! Both the Smartlist rules and list placeholder are working, thanks !
The 'problematic' identical named Album vs Artist is solved and the active album is excluded from the listing aswell :-)

Now I'm adapting listing towards images, as next (and final) step:
Would you please check me the following expression, and give me a pointer why it isn't finding or displaying any images ? I'm clearly missing something  ?
Code: [Select]
<font size="150x150"><img src="C:\JRiver Cover Art\Albums\[Album Artist (auto)] - Listclean(Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]);,Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2));,[Album];,),1).jpg">/ <img src="C:\JRiver Cover Art\Albums\[Album Artist (auto)] -/ ).jpg"><//font>
PS the initial expression does work, but as it doesn't exclude the active album, i'm trying to adapt it with the help of your other updated expression.
Paths are good:
Code: [Select]
<font size="150x150"><img src="C:\JRiver Cover Art\Albums\[Album Artist (auto)] - Replace(Clean(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]),Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2)),3),;/ ,.jpg">/ <img src="C:\JRiver Cover Art\Albums\[Album Artist (auto)] -/ ).jpg"><//font>

Thanks again sir !
Appreciated,
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: Simple expression help...
« Reply #26 on: May 07, 2020, 02:30:18 pm »

This worked for me with my paths:
Code: [Select]
<font size="300"><img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] - Replace(Clean(ListClean(Replace(RemoveLeft(Load(vAlbumsByArtist[Album Artist (auto)]);,Math(Find(Load(vAlbumsByArtist[Album Artist (auto)]),;)+2));,[Album];,),1),3),;,.jpg">/ <img src="D:\audio\Album Covers\Albums\[Album Artist (auto)] -/ ).jpg"><//font>
You might want to start learning yourself with little more simpler things to get you going and you'll soon get some basic understanding about the expressions.

Good luck and happy learning
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #27 on: May 07, 2020, 02:40:01 pm »

Thanks a lot Lepa !
Works perfectly now, my attempt was a couple of miles off  ;D
Your help is highly appreciated.
Take care and stay safe.

Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #28 on: July 21, 2020, 07:23:42 am »

Greatday Lepa,

Hoping you're doing fine ?

Lepa, once you've got a spare minute, would you mind looking at the expressions as above onto your system ?
Since the most recent builds, don't know exactly when, in some cases ONE album seems to be missing.
I've tested also .101 but still no luck.

The displayed count number is correct, but in half of the cases there's one alternative album missing by the same artist.
When selecting per Artist all albums are there and including artwork/cover art.
Browsing the JRiver Cover Art>Album folder: all are available.

I read about some expressions which may work differently or have changed/added parameters ?
Not sure the above is related,

Thanks again sir !
Logged

Mans

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Simple expression help...
« Reply #29 on: August 03, 2020, 05:26:52 am »

Greatday Lepa,

Hoping you're still doing fine sir,

Lepa do you have by change a minute of your time to verify the challenge which I'm noticing with those expressions.

Those expressions worked perfectly for me till some weeks ago.
As I've read somewhere this forum some expressions did get new or changed parameters, would this be the case ?

Thanks for your help man.

PS updated to .103 and still missing these random 1 covert arts per artist. The count is fine, but the displaying part is in 50% of the Artists of by 1 album.
Logged
Pages: [1]   Go Up