RobotStudio event

Copy to an Array

Hi guys, I'm sure there is a simple way of doing this. But i want to copy to an array based on a variable. my example is I have an array called:

PERS num nPickOffsetX{8}:=[1,2,3,4,5,6,0,0];

And a variable called:

VAR num nPatternNum:=0;

I want to copy into one of the two arrays below based on what number is is nPatternNum. So if it was 1 I copy into P1 if it's 2 I copy into P2

PERS num nPickOffsetX_LT0_P1{8}:=[0,0,0,0,0,0,0,0];
PERS num nPickOffsetX_LT0_P2{8}:=[0,0,0,0,0,0,0,0];

I realise I could use an "IF" function, however I want to be able to do this to an array size of about 150 of which there are 25 different variable in each array. So that is a lot of "IF"'s!

Any help would be appreciated?


Comments

  • What you are asking for is late binding. According to the RAPID Overview manual, late binding is only available for procedure calls.

    An alternative to using IF would be CASE, unless you figure out a clever way to utilize late binding for procedure calls to solve your problem.


    Henrik Berlin
    ABB
  • Hi
     

    You might be able to use the instruction called SetDataVal. Please see the Rapid Reference Manual, there is one example where SetDataVal is used with an array.

     

    -Osku


  • Another option would be to add a dimension to the array and use the first field for indexing, instead of coding it into the name.
    Henrik Berlin
    ABB