12.10.1    Transfer the value of a tag to another tag

 

# Tcl Transfer tag2 value to tag1 if they differ by more that 0.1

#(similar to DATA Transfer function).

# catch isolates error,

# allows next statement to execute rather than stopping entire script

catch {

if {[expr abs([GETVAL sp1]-[GETVAL sp2])] >= 0.1} then {

SETVAL sp1=@sp2} }

# abs is absolute value - either .1 more or .1 less

# @ sign refers to the contents of tag named sp2

# repeat for next set of tags

catch {

if {[expr abs([GETVAL sp1]-[GETVAL sp2])] >= 0.1} then {

SETVAL sp3=@sp4} }

The catch command  “catches” errors, allowing the rest of the script to run.  Without the catch, if there where in error in the last statement, for  example tags sp3 did not exist, then the whole script would fail