Click or drag to resize

ReadItem and WriteItem methods

Overview

An alternative way of accessing RAPID data stored in an array are the ReadItem and WriteItem methods.

ReadItem method

Using the ReadItem method you can directly access a RAPID data item in an array, for example an array with RobTargets or Nums. The index to the item is explicitly specified in the ReadItem call. The first item is in position 1, that is, the array is 1-based as in RAPID.

The following example retrieves the second Num value in the first array of the RAPID data variable referenced by rd.

C#
Num aNum = (Num)rd.ReadItem(1, 2);
VB
Dim aNum As Num
aNum = DirectCast(rd.ReadItem(1, 2), Num)
WriteItem method

It is possible to use the WriteItem method to write to an individual RAPID data item in an array. The following example shows how to write the result of an individual robot operation into an array representing a total robot program with several operations:

C#
Num aNum = new Num(OPERATION_OK);
rd.WriteItem(aNum, 1, 2);
VB
Dim aNum As Num = New Num(OPERATION_OK)
rd.WriteItem(aNum, 1, 2)
Note Note

If the index is not in the range specified, an IndexOutOfRangeException will be thrown.