ReadItem and WriteItem methods |
An alternative way of accessing RAPID data stored in an array are the ReadItem and WriteItem methods.
ReadItem methodUsing 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.
Num aNum = (Num)rd.ReadItem(1, 2);
Dim aNum As Num aNum = DirectCast(rd.ReadItem(1, 2), Num)
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:
Num aNum = new Num(OPERATION_OK); rd.WriteItem(aNum, 1, 2);
Dim aNum As Num = New Num(OPERATION_OK) rd.WriteItem(aNum, 1, 2)
![]() |
---|
If the index is not in the range specified, an IndexOutOfRangeException will be thrown. |