BillRobinson
Member
My root problem is accessing data from a 3 dimensional array...lets call it MY_ARRAY[24,12,100]. Now I want to access the data in the array based upon three parameters... say x,y and z; In this example I'll only want one parameter, so I want the value of MY_ARRAY[24,12,z] where z is any integer between 0 and 99.
Now I can do this from a RSLogix5000 ladder program, but I can't do this from a function block program. I get an error:
Language element can not refer to a variable array index.
So my next venture is to create an structured text Add-On instruction, which I get to work, only problem is that I can't do this for every possible array. That is, the dimensions of array used to write the add-on must match the one used in the add-on code. So let say in my add-on code I use an array that is [10,10,10]; if I want to use the same code on a [20,20,20] array I can't.
So two questions:
1) Is there a better way to access array elements in a FB program?
2) Is there a way to write an Add-ON instruction that will handle any n-sized Array?
Now I can do this from a RSLogix5000 ladder program, but I can't do this from a function block program. I get an error:
Language element can not refer to a variable array index.
So my next venture is to create an structured text Add-On instruction, which I get to work, only problem is that I can't do this for every possible array. That is, the dimensions of array used to write the add-on must match the one used in the add-on code. So let say in my add-on code I use an array that is [10,10,10]; if I want to use the same code on a [20,20,20] array I can't.
So two questions:
1) Is there a better way to access array elements in a FB program?
2) Is there a way to write an Add-ON instruction that will handle any n-sized Array?