Ditto. And I hope to see many more interesting ideas posted to the Scripting forum. I have been doing a bit of experimenting too and except to have something in a fit state (i.e. properly documented) to add soon. I'm sure we can all learn a lot from each other.
Toggle by itself doesn't work, because if the option is turned off Opus doesn't know what setting you want to toggle it on to. You need so specify toggle in conjunction with one of the other keywords (e.g. Set CALCFOLDERSIZES=local,toggle).
It's working fine here. (I tried Set CALCFOLDERSIZES=local,toggle.)
Note that you will not see folder sizes calculated until you refresh or change folders (since that is when automatic calculation happens, if it is on).
Also note that you won't see the Preferences option change if the Preferences dialog is open when you change it. (Cancel the dialog and re-open Prefs, and you should see it has changed. OTOH, if you click OK then you will overwrite the setting with what's shown in the Preferences dialog.) This is the same for most commands which toggle Preferences settings. The Preferences dialog takes a snapshot of the configuration, which you can then edit in the dialog, and finally either cancel (throwing away the snapshot) or apply (saving the snapshot over what the main program actually uses).
@Leo / Jon: For some reason, doing a 'Go REFRESH' after toggliing this option on doesn't work in [u]THE DEFAULT FOLDER [/u] opened when opening a new tab. Maybe that is something you'd consider a small bug? Also, what's the local option intended to do? I though maybe it was to operate only in the lister in which the option is toggled on on like my script or something, but that doesn't seem to be the case? I didn't have access to a network share in case it's for 'local' drives and not remote...?
@FunTanK: Leo's spot on, but depending on what their opinion on this is one potential drawback in doing a 'go refresh' is that it will lose whatever folder selection you may have made. Doing an explicit 'GetSizes' would also only calculate the 'selected' folders size.
In my script-based solution for this, I expected that most people who were turning the option on probably wanted all folders in the current folder to be calculated (at the moment the button is pressed to toggle auto sizing on). So in my version, I've implemented a variation on Jon's 'SmartGetSizes' command as a raw command that gets added to Opus which allows a GETALL option so that all folder sizes are calculated, regardless of any folders being selected or not, and also carried the NODESELECT option into this command so you don't lose whatever folder selection might be in effect when you run the command.
If that's of interest to you, I've attached here only the portion of my full solution which adds that new raw command (SmartGetSizes - all credit to Jon for the working code and name of the command ). You can then create your toggle button, and end the button with the command SmartGetSizes GETALL NODESELECT. To install the new command, just drag and drop the script OSP file attached to this post from a lister to the Preferences / Toolbars / Scripts page. After hitting Ok, you should then see 'SmartGetSizes' as an available command in the button editor and Customize->Commands dialog:
Ah, yeah ok - made sense and figured it was for local drives. Just couldn't test to verify it when I posted.
Anyway, I did some more testing - and it's obviously got nothing to do with the 'Set' command itself so much as the Prefs option it toggles. It looks like Opus treats the root of a library as a 'network' folder, at least - the only way I can get the sizes auto-calculated when I am listing the root of a lib, is to set the option to include network drives... If I set the default folder to anything else, it works on open with the option on. So there seems to be an issue - just not specific to "default folder" like I thought.