I am running simple script to get tag name but it ending up with an error:
"Error_ExpressionEval("Error executing script for runScript() expression:default.ReadIniFile.myFunc()")
Tag is connected to the PLC using OPC connection.
def myFunc(text="Hello World!", moreText="Good bye"):
Could someone please help on this?
Is your function defined in the project set as the Gateway Scripting Project?
If not it must be as tags operate outside of any project.
What is the line
supposed to do? There is no assignment operator.
Tip: format your code when posting on the forum.
Your expression is
but the path in your screengrab suggests that it should be
Thank you for your response.
How do I know function is defined as the Gateway Scripting Project?
Sorry, I am new to Igntion.
I tried with "generate", it still came back with same error
On the Gateway Page at Config > Gateway Settings, in the first section there is a place to set the Name of the Gateway Scripting Project.
If you are not editing the project with that name when you add your script to the Script Library, then it isn't in the Gateway Scripting Project.
It is empty which means it is not Gateway Scripting Project?
If it is the case then, I cannot use script in the UDT tag?
Thank you again
That is correct, if it is blank then there is no Gateway Scripting Project configured.
Scripts that run outside of a project scope (tag scripts, etc...) are not projects and therefore need to be told where to look for the script.
I believe that you can set the Gateway Scripting Project to the name of your project and it should work. If you are only ever going to have the one project this is probably fine, but if you intend to have more than one project, this should probably be a stand alone project.
Often this project is used as the root project and set to inheritable, then all other project inherit from it. That way things inside of the project will also have access to the script.
I did that
But it did not work.
Is runScript command line need change?
I tried to give it a same name.
but it did not work either.
It needs to be the project name, not the Gateway Name.
If you look on the Projects Tab in the gateway you can find the name that needs to be entered.
I tried following but it did not work.
Thank you for your support
I have also put the same name for Gateway scripting project
Do I need to restart designer after changing the name ?
Okay, let me try to step through this a little bit.
- Set your Gateway Scripting Project to the name of your project. From your screen shot this looks to be
- In your
runScript expression you need to use the proper path to your function. From your screen shots this looks like it should be:
runScript requires a poll rate be included.
Make those changes and then try this in the expression:
It did work.
Thank You very much for your help.