I have created a Named Query that inserts two parameters (values) into a table. I would like to have a Gateway Tag Change Script that runs the Named Query when a PLC tag changes and provides the PLC values to the Named Query.
Here is my admittedly very ugly Gateway Tag Change Script:
yup you are correct. I copy-pasted and left out the row starting with "def". But then I was getting errors and adding the "def" line in fixed it. Once this project is over im going back to the basics to learn from the ground up. Thanks for all your help,lrose.
@lrose I really like your idea of using the library object. I set up the def insertCycleData() script in the project library and then changed my Gateway Tag Change Script to LibraryName.insertCycleData(). It did not work, so I hardcoded values and simplified it as much as possible to learn how it works. I could not get it to work. Is there more setup I need with this method?
LibraryName is just a place holder. So, for instance say you added a new script to the project library that you named, myScript. You place your function definition inside of that script resource.
Then you would call that like this:
myScript.insertCycleData()
Since I don't know what you named your script resource (or if you placed it in a folder) then I cant tell you exactly what the call should be. So long as the script and event are defined inside the same project there is nothing else that needs to be done for this to work.
I actually should have included that part in my answer.
There are weird things happening in gateway event scripts and you should get the habit of not coding in them, but just calling scripts that are in your library.
I moved my script into a library script per these recommendations. Now when I save my project, my table gets an overlay error until the process is ran and it updates. Is there a way to avoid this?