Define expression from a string parameter

I need to evaluate some dynamically defined expressions, that are created outside of the tag editor.

I am fairly certain I could do it with a system.tag.configure and then just define the expression there,

However would it be possible to define the expression in a UDT parameter and then evaluate it inside the expression editor?

Something to the affect of expression({expressionParam}, 5000) or is that just wishful thinking? Where expressionParam = toMillis(now(5000)) or something similar.

I think I could just use runScript here and python instead, but that feels dirtier than an expression for some reason.

Pretty sure you crash into a wall here. I’ll bet system.tag.configure will want the compiled expression, which you cannot generate. Let us know if you find different.

Crude test, but this worked

tag = {
  "valueSource": "expr",
  "expression": "toMillis(now(5000))",
  "dataType": "Int8",
  "name": "New Tag",
  "tagType": "AtomicTag"
}

system.tag.configure("Test", tag)
2 Likes