How to get the NAME of the out-of-bounds array...

BlitzMax Forums/BlitzMax Programming/How to get the NAME of the out-of-bounds array...

Russell(Posted 2008) [#1]
If I have a line that has many arrays (or functions which have their own arrays - even BRL's own) and I get an 'attempt to access array element beyond array length' error, how do I know which one it was? Is it possible to find the name of the array in question (Rather than spend possibly a large amount of time eliminating the other possibilities)?

Sure would be handy!

Thanks,
Russell


tonyg(Posted 2008) [#2]
I understand what you're saying.
Generally my lines are pretty short (even if I *could* do it in one line I subdivide it for readability) so it's obvious which array is in error.
If you supply an example I might be able to say how I would code the same. Might not help but you never know.


Russell(Posted 2008) [#3]
I, too, try to limit what I have on a line (and I comment super-liberally...), but occasionally having multiple arrays or array-references on a line can't be helped. To be honest, I'm a bit surprised that the name of the array isn't given on error. Seems like a no-brainer to me!

Russell


plash(Posted 2008) [#4]
You'll just have to separate the lines out to see which is the cause.


Russell(Posted 2008) [#5]
More than once a BRL function turned out to be the cause, and I won't be going into BMax's source code, thank-you-very-much! ;)

Still, how hard could this be to implement? Wouldn't the name of the offending variable be included in BMax's thrown exception?

Is there a way for ME to catch this during debugging? According to the docs, a TArrayBoundsException is thrown when an array is out of bounds. Can I catch this and get the variable name myself? If so, how might one do that (Runnable examples, please :)

Russell