Hi guys,
I just get confused about where is the best place I can use the runScript function. Because I saw some of it say if the runScript written inside the expression tag it will cause the GUI to hang/ delay.
Will this causes the GUI to hang/delay if I configured as expression tag and bind it to the alarm indicator?
No, it won't cause a UI hang, but if you have too many of these and the queryStatus call is too slow (hint: it probably is too slow) it will start to "gum up" your tag system and you'll have other problems.
It's best to do this kind of thing in a dedicated timer script and then periodically write the calculations you're interested in to memory tags, or something like that.
Generally, if you're using runScript to do anything other than call a simple scripting function that exists because a suitable expression function doesn't exist, then you may be abusing/mis-using runScript in a way that will eventually break your system.
Just out of curiosity. Would using runScript in an expression tag to run a custom script that performs a lookup of a folder of tags and populates a dataset expression tag to be linked to a table for viewing be bad for the system? I have a couple set up this way as it was the best/most maintainable way I came up with to basically make an auto-update table if new tags were added to that provider. I haven't noticed any issues so far. But if this could potentially cause issues down the road I would much rather fix it now then when the system breaks lol. If this is not a good way of doing it, is there another way of having table data populate with the new tags when new tags are added that would not be considered bad for the system?
runScript() in an expression tag whose purpose is anything more than trivial, such as DB queries, network callouts, dataset construction, and kind of browsing, or stuff that might take more than single digit milliseconds, should be moved to a timer event script (calling out to a project library script, ideally). There is a limited thread pool for expression tags, and long-running runScript calls abuse that, and can block that for the entire system.
so the expression tags I use it for are just for creating a dataset based off of a folder of tags I created for table viewing. And when I timed it only took like 3 or 4 milliseconds to complete I believe is what I had. So that shouldn't cause any issues then should it? Or would you still recommend to run that somewhere else? Or did I misunderstand and you meant dataset construction should not be done in an expression tag as well?
no just 2 or 3 at the moment and they only run every 5 seconds but I could also lower that timing to be more spread out as well if needed. I don't anticipate having to create any more but if I do I may look into trying it a different way. Thanks for the input. I try to do design my projects in the best way I can but I'm definitely still learning new tricks and best practices so I welcome any helpful insights from anyone that knows better than I do what could go wrong. Wanted to make sure I wasn't doing something that would cause issues later that I did not think of or see at the moment.