I think I (finally) get it now. The variables are only valid for a single "run" of any given view (so, during MC's "execution" of a view calculation). They are scoped to the method call that produces the view, and not like a (true, ugly) global variable like would be used by a junky vbscript or whatever. Am I getting that?
So, for example, if you forget all about COM, and I just did it the way you (recently) suggested with a calculated field. The field I'd be making would simply output 0 for any file that should be kept, and 1 for any file that should be deleted (say [Should Be Deleted]).
Well, a regular, simple true/false field in the Library, could
normally be used as a filter in a smartlist (of course). So, if that User Field worked like a regular one from the Library, you could just make a list that looks for [Should Be Deleted]=>0 and show only those results, via the Files to Show search. But, if what I think I understand now is true, that still wouldn't work regardless of what happened in any user interaction before the current "view refresh". If the field is calculated based on a save()/load() pair, and there is no save() statement
within that view's definition, then you can't do it. Even if I was running these manually (physically clicking on one, then the other, in MC's UI)...
1. My field would work when I click on the smartlist that runs the search including the save() statements. If that view/list has a column that displays the [Should Be Deleted] field it would work right from within this view or smartlist.
2. When I switch away to another list or view that tries to use [Should Be Deleted], the load() variable will be undefined again, because the variable no longer exists in the context of that "view refresh".
You see, I've never really understood them before. And I think that's because they've been called "global variables" which made me think they were something they're not. You can use them to pass information from the search to each "result" essentially (so, a good use would be a calculated column), but you
can't use them to pass information from one view to another.
I think if you are relying entirely on smartlist processing, you'll be a little limited.
Even though you get the smartlist via COM, it would still calculate the variables used within a successful search query. To get access to those variables, you'd need to create a custom user field, and set the expression to the load() expression necessary to produce the value you want. The results should be valid once the smartlist runs (via COM should be fine), and (essentially) undefined before then. Once you have your list of files, you'd have to ask MC for that field for each of your file objects so you can make decisions based on those values.
Yes, I could do it that way, but I'd have to custom code something that iterates over the Smartlist and looks at the value of that field (like MCAutoQueue pulls the value of the [Needs Processing] field and uses it to decide which processor to use for the file).
My hope was to avoid that and to keep the remover utility "stupid" and all it does is delete or remove all of the files in a given playlist.
I could do all of that, but honestly, it would be easier just to custom code the whole thing then, and not use MC's global variables at all. I'd just write a utility that figures out the [Should Be Deleted] value itself (which it can do pretty easily by doing a search or two an then LINQ-querying the resulting list), and then writes this value to a regular (persistent) Library Field for each file record. Then I can make my File Removing smartlist because it is a real field, and so long as I run step 1 beforehand, it would have fresh results.
But, I don't care enough to do all of that, I don't think.
Basically, the 1 week expiration is good enough for all of my needs except for a few of my News programs. I have Sage set to record every episode of BBC News that airs on BBC America and PBS, for example. And, the NBC Nightly News and I think one "evening news" program on CNN or MSNBC or something too (I don't watch these very much so I don't even remember which I have set up). For the BBC News "recording favorite" I have shows to keep set in Sage to 3 (because it airs a few times a day, so it keeps the last 36 hours or so worth of versions of the news program), and for all the other ones I have it set to 1 (it keeps the last one recorded, and no others).
That works fine as it is, of course, so I could just leave it alone. But, I was hoping to replicate that part in MC, and then I could use MCFileRemover to do it (which avoids the orphaned sidecar file problem).
But... It is the path of least resistance to just use the time-based expiration system I already have. I could, of course, just make the [Weeks to Keep] field a [Days to Keep] field instead, and put 1 or 2 in there. I didn't want to do that because the typical values I have for [Weeks to Keep] (other than these couple news items) are 1-3 months. I like to keep the numbers small, and entering 4, 6, or 9 weeks is easier than using 30, 45, 60, 90, etc days when manually tagging the Series.
The path of less resistance would be to just abandon the "Number to Keep" and change my [Weeks to Keep] system to [Days to Keep]. The path of least resistance, however, is to just keep using Weeks and use 1 for all of those News programs above described, or just turn their recording off entirely, since I almost
never actually, you know, watch them.
And that's what I think I'll do.
It is too bad, though, and it would be nice to have a solution for this within MC's expression language. I've hit this wall before, with my desire to make the "currently watching" view for Theater View. You can calculate anything you want about the files themselves, but you can't (easily) calculate much about groupings of those files based on their tags (in an abstract and flexible way)...
If [Rating]=>2 then do X with the file <<< is easy to do.
If any one file in a group (a particular [Artist], for example) has [Rating]=>2 then do something with all members of the group <<< is hard to do.
I think a great goal for them with the expression language would be to solve that problem.