Cicode Programming Reference > Cicode Function Categories > Tag Functions > TagWriteIntArray

TagWriteIntArray

This function writes an array of integers to a tag. You can write to all elements of an array tag, or write to a subset. Use the Offset parameter to write to the subset (e.g. if you specify a Length of 5 and an Offset of 2, you will write to the 3rd, 4th, 5th, 6th and 7th elements in the tag array).

Note:For this function to be successful a user needs to be logged in.

This function completes asynchronously to the caller. It will be unsuccessful if the tag does not exist or if a write request could not be sent. This function does not test whether the write succeeded. In cases where the write does not succeed, TagWriteIntArray does not return a driver error code. You can use the TagReadEx function to confirm the write operation took place.

TagWriteIntArray should only be used when the variable tag name is a calculation such as sAlarmExt+".Paging". For assignment of variables use the assignment operator. For example, MyCluster.MyAlarm.MyProperty = MyString.

Note: When using this function and parameter [Code]ScaleCheck is set to 1, the attempt to write an out-of-range value to a device will not occur. No hardware alarm will be generated. This function checks a value before writing it to a PLC.

Syntax

TagWriteIntArray(STRING Tag, INT Length, VAR LONG Values, INT Offset, INT Sync, STRING ClusterName)

Tag:

The string can refer to either: the variable tag name, the equipment and item name (using equipment.item notation) associated with that tag, the alarm name and the alarm property name, the tag name and the tag element name (Refer to Tag Extensions for more information). If the element name is not specified, the writing will be performed to the Field VQT element. The name of the tag can be prefixed by the name of the cluster that is "ClusterName.Tag" or "ClusterName.Equipment.Item".

Note: If the tag name exceeds the length limit of 254 characters the hardware alarm "Tag name exceed length limit" will be raised.

Length:

The number of elements written to the tag.

Value:

The element you select in the array to be the first. The array contains the values you are writing to the variable tag. See example below. Must be a Long type variable.

Offset:

Optional offset inside the variable tag array where you start writing to. Default is 0.

Sync:

An optional boolean argument that specifies whether the command is synchronous (blocking) or asynchronous (non- blocking). If it is specified as synchronous (blocking) the function will wait until the write has completed and returned from the server before further code execution. This parameter is "False", or asynchronous, by default. If you specify this parameter the rest of the parameters need to be explicitly specified, including nOffset which should be set as 0 if the tag is not an array tag.

ClusterName:

Specifies the name of the cluster in which the Tag resides. The argument is enclosed in quotation marks.

Return Value

0 (zero) if successful, otherwise an error code is returned.

Related Functions

TagRead, TagReadEx, IODeviceControl, IODeviceInfo

Example

	GLOBAL INT ArrayOfInts[64];

	FUNCTION ArrayWriteAscendingInts()
		INT i = 0;
		FOR i = 0 TO 63 DO
		ArrayOfInts[i] = i;
		END	
	
		TagWriteIntArray("ModnetIntArray", 64, ArrayOfInts[0]);
	END

See Also

Tag Functions

Published June 2018