Derived Tag using runScript in Write Expression errors out, even in simplest case

I am trying to run a script to handle my Write Expression in a Derived tag. I wrote a script that simply returns a value, and call it in the Write Expression, and when I try to change the value of the tag, all I get is

Error writing to setpoint.value: Error_ExpressionEval 

I have tried to replace runScript("MyScripts.static_value") with the actual value of static_value, and it works just fine. But I can't seem to get the script to run in the same spot!

def static_value():
    return 0.333

Is this not possible? I can select runScript from the binding popup that comes with the control itself, I am not forcing it into a place it is not to be selected, so I am not sure. The documentation for runScript mentions nothing about not being allowed to use these in a Derived tag.

Also, is there a way to get a more verbose Error_ExpressionEval?

Do you have the gateway scripting project set?

2 Likes

Where do I set this? I can't find anything in Project Properties, nor obviously in the Gateway Config. I changed the "Script Hint Scop" to Gateway to no apparent effect.

https://docs.inductiveautomation.com/display/DOC80/Project+Library#ProjectLibrary-GatewayScriptingProject

That did it, thank you. Hidden in Gateway Settings!

I guess I should just have a single project with all of my scripts?

Generally not. I recommend:

  • an inheritable project with all of your extremely-well-tested generic functions, to be your root "global" project,

  • zero or more inheritable projects (themselves inheriting root) with common GUI elements for sections of your project "tree",

  • a leaf project with all of the functions your tag events need (inheriting from root), to be your global scripting project, and

  • other leaf projects to be actual UIs and leaf projects to encapsulate complex gateway-only tasks.

2 Likes