Search the Community

Showing results for tags 'subscripts'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Found 1 result

  1. Array A INT[32] Array Index B INT Destination C INT I am trying to move an Array (A) Element (A[2]) using a symbol (B) in ladder into a destination symbol (C) C = A [ B ] Result: ERROR: Array Index of Operand 1 out of range at rung 1 ( 6, 0 ).  The documentation suggests that it is possible, but I am unsure if there is something I am doing incorrectly. Note* Fixed indexing works with no errors Is there another method to accomplish this?   PLC : CJ2M CPU31 CX- Programmer: Verion 9.74 Update 1: If I go online to the PLC It does look like the array look up is working. Is the issue with the mov block? Update 2: I changed the memory locations which has caused a different error to appear. This error is clearer but does not explain the manual excerpt I posted further up ERROR: Only the constant can be specified for the index of the array.  at rung 5 ( 6, 0 ).  Update 3: Solution 1 I managed to hack together a proof of concept using pointers and indirect offsets  Update 4: Solution 2 For some strange reason things work as expected inside of the function blocks so I made one where the array is In-Out and with an input and output respectively. Note* External reference to pointers inside of the function block produced an error. Function block Logic     Update 5: Solution 3 Now I feel like I am going crazy, I tried just the original code again and it works... I have no idea why and if it was not for all the documentation I would be lost as to why it works now... Update 6: Conclusion It seems to have array indexing work the array index must exist in the D Memory Block. The reason it did not work above is because I somehow had a MOVR block when I tested after moving all the variables to the D Memory Block. I hope this journey helps someone else :)