INTERACT FORUM

Please login or register.

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

Author Topic: Can't get Save() Load() global variables to work. Please Help  (Read 852 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 124
Can't get Save() Load() global variables to work. Please Help
« on: January 02, 2022, 07:26:19 pm »

I want to run a Smartlist that captures into global variables the quantity of tunes from the 60's, 70's, 80's, 90's, 00's, 10's, and 20's that I want other Smartlists to use to limit the number of tracks via the "Limit Number to" modifier. I prepared one Smartlist with a "Custom" command to create a global variable called "var_np_1960" and assign it a value. Next I prepared a Smartlist to select songs from that decade limiting the number of tracks to "var_np_1960". Thought it would work, however, it is clear I am doing something wrong. Can someone please help?
Logged

EnglishTiger

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1084
Logged
Apple Mac Mini Desktop Computer with M4 Pro chip with 12 core CPU and 16 core GPU: 24GB Unified Memory, 512GB SSD Storage, Gigabit Ethernet, 3 Thunderbolt5 + 2USBC ports.

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #2 on: January 03, 2022, 04:26:22 am »

You want the [1]=1 logic in there to force evaluation and trigger the save

eg
Code: [Select]
[=save(1,v_albuminstrumental[albumunique])1]=1
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #3 on: January 03, 2022, 04:27:46 am »

Also, if an expression doesn't work directly you sometimes have to put it in a user field and use that instead, so your limit expression may not work as expected with the load() function.  If not stick the load() into a user defined field and then it will work.
Logged

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #4 on: January 03, 2022, 04:28:56 am »

When building such views it's always helpful to add an expression column to the view in which you display the contents of the variable so you can see whether the logic is working as expected.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #5 on: January 03, 2022, 05:03:06 am »

Another problem with setting your global variables in a Playlist is that globals are not persistent - when you restart MC, all of them are gone. So you would always need to open that Globals playlist at least once before your other playlists that use them can work.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 124
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #6 on: January 03, 2022, 07:40:42 am »

You all are awesome! Thanks so much for the quick replies, unfortunately my wife told me to stop farkeling with this and watch TV with her. This morning I tried your suggestions and I am halfway there; have the save() part working, stuck on the Load() part.

Attached are a couple of screen shots.

When I added the Load(var_np_1960) to the "Limit Number to" and click apply I get nothing. If I remove the modifier I see that the global variable displays the value set by the previous Smartlist. One of your comments suggested that "you sometimes have to put it in a user field and use that instead." Can you please elaborate? Where do I create a user field? and how to I add the Load() command to it?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #7 on: January 03, 2022, 08:38:29 am »

I think you can't use expressions on the playlist modifiers, at least on the Limit one it doesn't seem to work with any expression.
Perhaps you can request this as a new feature.
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 124
Re: Can't get Save() Load() global variables to work. Please Help
« Reply #8 on: January 03, 2022, 12:49:28 pm »

Thanks for the feedback and everyone's help. Submitted a Feature Request to allow Global variables to be used in Smartlist modifiers. Locking this topic
Logged
Pages: [1]   Go Up