Basic array question.
 
            
                
                    nezzreth                
                
                     ✭                
            
                        
                
                                    
                                  in RobotStudio             
            
                    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.
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?
                
                        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.
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, <b>row</b>*12.7, <b>column</b>*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?
            Tagged:
            
        
0  
            Best Answer
- 
            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
 5
Answers
- 
            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 0 0
Categories
- All Categories
- 5.6K RobotStudio
- 401 UpFeed
- 21 Tutorials
- 15 RobotApps
- 306 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.9K Robot Controller
- 363 IRC5
- 80 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 853 RAPID Programming
- 31 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 110 Collaborative Robots
- 5 Job listings
