IOSetItem() Function
- Last UpdatedFeb 22, 2017
- 2 minute read
You can implement Dynamic Reference Addressing by using the IOSetItem() function within a script. IOSetItem() includes arguments to change the values assigned to the .Reference dotfield of an I/O tag during run time.
Category
Miscellaneous
Syntax
IoSetItem ("Tag", "AccessName", "Item");
Arguments
Tag
Any InTouch I/O tag enclosed in quotation marks.
AccessName
The Access Name assigned to the I/O tag.
Item
The Item assigned to the I/O tag.
The Tag, AccessName, and Item arguments can be specified as literal strings or they can be string values provided by other InTouch tags or functions.
Examples
In the following example, the .Reference dotfield of the PumpInP1 tag is changed to point to the excel Access Name and the R1C1 item.
IOSetItem("PumpInP1", "excel", "R1C1");
or
Number = 1;
TagNameString = "PumpInP" + Text(Number,"#");
IOSetItem(TagNameString, "excel", "R1C1");
If an empty string ("") is specified for both the Access Name and item values, then the tag is deactivated. For example, the PumpInP2 tag is deactivated by:
IOSetItem("PumpInp2", "", "");
If a null is specified only for an item, then the tag’s current item value is retained and its Access Name value is updated. For example, the following changes the Access Name for the PumpInP3 tag to excel2 without affecting its current Item value:
IOSetItem("PumpInP3", "excel2", "");
Likewise, if a null string is specified only for an Access Name, then the tag’s current Access Name value is retained and its item value is updated. The following example changes the Item for the PumpInP4 tag to R1C2 without affecting its current Access Name value:
IOSetItem("PumpInP4", "", "R1C2");