INTERACT FORUM

Please login or register.

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

Author Topic: Expression to automatically determine number of discs in a set  (Read 2065 times)

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Expression to automatically determine number of discs in a set
« on: November 13, 2017, 03:27:01 pm »

I'm trying to figure out if there is an expression that can be used for a "Disc # of" Library Field that can automatically set to the number of discs that share the same album name. So, for instance, if my "Sgt. Pepper's Lonely Hearts Club Band" has 5 discs tagged in the set, the "Disc # of" tag would set to 5. If I added a new disc to the set, the "Disc # of" tag would automatically update to 6 without any intervention.

I feel like the expression is on the tip of my tongue but I don't quite have the knowledge to pull it off. Expression gurus, do you have some advice?
Logged

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7402
  • The color of Spring...
Re: Expression to automatically determine number of discs in a set
« Reply #1 on: November 13, 2017, 03:39:15 pm »

Total Discs field is probably what you want.
Logged
I don't work for JRiver... I help keep the forums safe from Viagra and other sources of sketchy pharmaceuticals.

Windows 11 2024 Update (24H2) 64-bit + Ubuntu 24.04 LTS Noble Numbat 64-bit | Windows 11 2023 Update (23H2) 64-bit (Intel N305 Fanless NUC 16GB RAM/256GB NVMe SSD)
JRiver Media Center 32 (Windows + Linux) | iFi ZEN DAC 3 | Edifier R2000DB Bookshelf Speakers | Audio-Technica ATH-M50x Headphones

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #2 on: November 13, 2017, 03:45:58 pm »

Answering my own question, I found an answer here that appears to be working: https://yabb.jriver.com/interact/index.php?topic=85233.0
Logged

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #3 on: November 13, 2017, 04:26:15 pm »

Ok I guess I was presumptuous. Something isn't working and I can't figure out what. In the post I linked to, MrC suggested this expression to determine the number of discs:

firstnotempty([Disc #,0],1) of load(v_discs_[album artist (auto)]_[album])

When I first used this expression in the Total Discs tag, it seemed to work. However, when I attempted to add a new disc to a album set, it did not update. Even weirder, after I closed JRiver and reopened it (thinking it might refresh), not it doesn't report any value for the total number of discs. So I just get "4 of" as the reply for the 4th disc instead of "4 of 4."

Confused.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression to automatically determine number of discs in a set
« Reply #4 on: November 13, 2017, 04:34:09 pm »

Where did you "save" the variable?

Variables can operate strangely.  I usually "save" in a smart list, then load in a maintenance view, where I transfer the value to a standard field. 

Then normal views have no calculations and are much faster.  this can mean some small amount of manual intervention, but then it always works.

also, check that your [album artist (auto)] are indeed the same, since you've set it in the variable they need to be precisely identical.
Logged

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #5 on: November 13, 2017, 05:13:48 pm »

I had actually created a new library field and set it be 'expression' and then pasted the expression in there. Is that not a good way to do it?

Edit: And yes, I checked the Album Artist (Auto) to make sure it was all the same.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression to automatically determine number of discs in a set
« Reply #6 on: November 13, 2017, 06:00:36 pm »

Try saving in a smartlist, and loading in a library field
Logged

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #7 on: November 13, 2017, 06:42:04 pm »

I'm honestly not sure how to do that. Researching the "load" command though, it seems it's made to load a global variable, which wouldn't apply properly to the individual albums as it would be global. I'm not sure I'm understanding that right though?
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression to automatically determine number of discs in a set
« Reply #8 on: November 13, 2017, 07:34:32 pm »

what expression(s) are you pasting? 

forgive my confusion.  a variable requires two parts: save and load.  IMO it's best to save in a smartlist (easily refreshed) and loaded in a field or view.

there are really only global variables. 

https://wiki.jriver.com/index.php/Global_Variables
Logged

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #9 on: November 13, 2017, 07:43:59 pm »

Ok sorry, I wasn't quite understanding what was going on. Yes, I had not set up the 'Save' part of the function, and thus my 'Load' was not working. After researching this I found this thread (https://yabb.jriver.com/interact/index.php?topic=79763.0) that walked through the steps. I'm still not entirely sure of the context, but I do understand that the View is setting the global variable which the Library Field can then pick up and parse. This appears to be working now. Thanks for your help.
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression to automatically determine number of discs in a set
« Reply #10 on: November 13, 2017, 07:57:54 pm »

FYI you don't need all the underscores

https://yabb.jriver.com/interact/index.php/topic,108605.msg752346.html#msg752346

this one has some explanations on what is happening with variables...they are still a bit of mystery though :)
Logged

Mike Foran

  • World Citizen
  • ***
  • Posts: 212
Re: Expression to automatically determine number of discs in a set
« Reply #11 on: November 13, 2017, 08:59:42 pm »

LOL yeah a mystery indeed. I hope to figure it out someday. Thanks for all your help!  :) :)
Logged
Pages: [1]   Go Up