# Basic array question.

**URL:** <https://tech-community.robotics.abb.com/t/basic-array-question/7893>\
**Category:** RobotStudio\
**Tags:** offset, array, rapid-code, help\
**Created:** [September 8, 2017, 7:17pm UTC](https://tech-community.robotics.abb.com/t/basic-array-question/7893 "2017-09-08T19:17:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nezzreth](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/nezzreth/32/1872_2.png) [@nezzreth](https://tech-community.robotics.abb.com/u/nezzreth)\
**Post date:** [September 8, 2017, 7:17pm UTC](https://tech-community.robotics.abb.com/t/basic-array-question/7893/1 "2017-09-08T19:17:01Z")

</div>

I am trying to figure out how to use arrays.  
The manuals are very confusing (for me) about this topic.

As an example, I would like to store some numbers in an array to use for offsetting from a position.

```auto
PERS num nMyArray{2,3}:=[[1,2],[3,4],[5,6]];
CONST robtarget centerpos:=[[-490.16,1517.62,1804.67],[0.262408,-0.265629,-0.646938,0.664872],[1,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

PROC main()
  spraypos:=Offs(centerpos, **row*** 12.7, **column*** 12.7, 0);
  MoveL spraypos, v400, fine, t_spray;
ENDPROC

```

In the example above, I want to offset the robtarget centerpos by calling the data from the array to replace **row** and **column**.

How do I format the syntax to make that happen?  
If I wanted to replace **row** with **5** and **column** with **2** how do I code that?

---

<div class="post-metadata">

**Author:** ![soup](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/soup/32/1592_2.png) [@soup](https://tech-community.robotics.abb.com/u/soup)\
**Post date:** [September 8, 2017, 8:52pm UTC](https://tech-community.robotics.abb.com/t/basic-array-question/7893/2 "2017-09-08T20:52:09Z")

</div>

Give this a shot:

MODULE mArrays

PERS num nMyArray{3,2}:=[[1,2],[3,4],[5,6]];  
CONST robtarget centerpos:=[[-490.16,1517.62,1804.67],[0.262408,-0.265629,-0.646938,0.664872],[1,0,-1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

VAR robtarget spraypos;  
VAR tooldata t\_spray;  
VAR num row;  
VAR num column;

PROC main()  
row:=nMyArray{3,1};  
column:=nMyArray{3,2};  
TPErase;  
TPWrite "Row = “+NumToStr(row,0)+” Column = "+NumToStr(column,0);  
!spraypos:=Offs(centerpos, row_12.7, column_12.7, 0);  
!MoveL spraypos, v400, fine, t\_spray;  
ENDPROC

ENDMODULE

---

<div class="post-metadata">

**Author:** ![nezzreth](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/nezzreth/32/1872_2.png) [@nezzreth](https://tech-community.robotics.abb.com/u/nezzreth)\
**Post date:** [September 9, 2017, 1:11am UTC](https://tech-community.robotics.abb.com/t/basic-array-question/7893/3 "2017-09-09T01:11:31Z")

</div>

Thank you very much! Most of the mystery has been solved.  
Now I just need to figure out how to define and index a 3D array 😃
