system.tag.writeBlocking VS system.tag.write, When should I use writeBlocking?

All of the examples given to me from prior projects have scripts using system.tag.write. Seems to work well. But when I use the scripting helper, for example on a button, Select "Set Tag Value", the result is writeblocking. Is there anything negative about a writeBlocking that I should avoid by changing the button scripts to nonblocking?

System.tag.write is deprecated, but kept around to not break scripts on the upgrade from V7.x to V8.x of Ignition. If you are developing new projects, you should be using writeBlocking or writeAsync.

writeBlocking also is more efficient when passed a list of tags and values instead of multiple calls to writing single to tags. Consolidating all of your write calls to a single call of system.tag.writeblocking at the end of the script is the preferred approach. There are obviously cases where this is not possible.

A difference between the two functions is whether or not the script waits for the write to finish.

Depreciated functions: system.tag.write | Ignition User Manual

Writes a value to a tag. Note that this function writes asynchronously. This means that the function does not wait for the write to occur before returning - the write occurs sometime later on a different thread.

Meanwhile, system.tag.writeBlocking | Ignition User Manual

Writes values to tags at the given paths. This function will "block" until the write operation is complete or times out. Meaning, execution of the calling script will pause until this function finishes. This is useful in cases where the tag write must complete before further lines in the same script should execute.

Technically the closest thing to system.tag.write would be system.tag.writeAsync as it will not block the script waiting for the write to finish.

2 Likes