Loading custom params from a table

Goal: Save custom parameters as a UTF-8 table. Load the params and copy them into an op. If an expr was used, set it. Set the parameters mode to whatever the user last set- constant or expression.

Surprisingly, I actually read the docs for this one but it’s the disastrous opposite of my expectation! I’ve killed 8 hours of my life so far. Is this even possible via code or only via User? So far, I’ve got to the point where it all seems to work but the expr does not evaluate!?

Any pointers much appreciated.

Thank You

Perhaps you’ll find what you want in the TDJSON module

Thanks. Saving and Loading are working- it’s the transfer of expr and getting it to work that is baffling me. Do you have a working example of that?


Somewhere on that TDJSON docs page you’ll see:

To set values, expressions, or bind expressions, provide ‘val’, ‘expr’, or ‘bindExpr’ in JSON.

So if you check the json you’ve exported you’ll see that by default in the definition of a par the current value or parameter state is not exported.

extraAttrs - (Optional) a list or tuple of attribute names that are not normally stored as part of a parameter’s definition e.g. ‘val’ and ‘order’. Can also be a string: ‘*’ indicating all properties of the parameter.

TLDR; use it like this:
export = TDJSON.opToJSONOp(op("test"), extraAttrs="*", forceAttrLists=True)

example attached:
export_and_import_pars.tox (1.9 KB)

Thanks. Your solution works but I only need (and have legacy data that uses) name, value, expr, mode

Turns out, The Nightmare was caused by setting incorrect expr, defaultExpr, mode and defaultMode values thus turning the ops params into a minefield that is saved between TD sessions.

Lol. Not. A lesson learned the hard way.