Array out of Bound

Hello, I need some helping trying to figure out what it means "array reference out of bound (0x23 - 0x1 - 0x19) ". My method keeps aborting, and I cannot figure out why. Any help/guidance would be greatly appreciated.

Hi @automation_viome and welcome to the forum!

This is a common runtime error when using arrays. Arrays are a useful data structure which maintain an ordered collection of elements, whose values can be returned via their index (their position in the ‘list’). Method editor supports arrays of variables (int, flt , str) and sequences as elements. Arrays can be instantiated as defined or undefined size.

‘Array reference out of bounds’ means there is a bug in the method code, where a particular line is attempting to retrieve an element from an array that is either empty, or smaller in size relative to the requested index.

If you can upload a run trace and a method pkg, we can point you in the right direction. You can upload to the following location (password is Hamilton24):

https://download.hamiltonsupport.com/wl/?id=l5J9xI1LzfBMAkUAmW4M2EGsgCVNz0Kq

Thanks.

-Nick

1 Like

@NickHealy_Hamilton Thank you for the advice. I just uploaded the files to the website you provided. Thank you so much!!!

The error is occurring at the very end of the method (line 926 in method editor). The value of the variable ‘var_ReagentsUsed’ is larger than the size of the array ‘array_Reagents’. The scripts is trying to retrieve an element value at an index that does not exist for the array, which is triggering the error.

image

If the purpose of ‘var_ReagentsUsed’ is simply to keep track of how many reagent names are contained in the array, I would simply get the size of the array prior to setting the iteration requirements of the for loop, and use that variable value to set the number of loop iterations.

Thanks.

-Nick

2 Likes

@NickHealy_Hamilton It worked! Thank you so much for you help!!!

2 Likes