Using runScript() to define the value for an expression tag

I’m having trouble using the runScript() expression function to set the value of an expression tag.

I first created a new project script called myTest. The function is defined as follows:

def myTest(num):
   return num

If I call this function in an actionPerformed event on a button then the script function executes just fine. The syntax used in this case is:

a = app.MyScripts.TestScripts.myTest('test')
print a

But if I try to call this function to define the value for an expression tag, then the tag quality always shows as ‘Evaluation Error’. The syntax I use to call the function is:

runScript("app.MyScripts.TestScripts.myTest('test')")

Any suggestions on what I may be doing wrong? I’ve attached some screen shots as well.

You cannot call an app.* module function in runScript on an expression tag.

The reason is because expression tags do not belong to any project but app.* modules and functions do. So an expression tag doesn’t know which project’s app.* module you might be referring to.

This will probably change in Ignition 7.7 when multi-project Python modules can be added.