Removing elements from a Struct in custom code

I have a single dim array of Structs called ‘References ’, and each element in this array has a number of fields (CustType, CustNumber, etc). Based on a condition, I need to remove elements from this References array, then feed the resulting altered structure into the next operation (which will convert it to XML, etc…)

I can loop through that array, but I can’t seem to alter it - setting a References[i] = null, causes errors at runtime.

Any other suggestions on how to accomplish this task?!

I am guessing that you are getting NullPointerExceptions at runtime. If not, please let us know what error you are getting.

This is a Java problem that you are running into. Remember that in Java you are always dealing with object references. Now I am not sure what is going on but I can guess. You are handed an object reference to an array of Structs called References. Please take note of what I refer to as object references is very different from the References that you have named your array of structs.

Now, when you alter the array, that’s good enough for you, but some other code may still have an object reference to the array and it is assuming that none of the entries are null. When it encounters a null where it isn’t expected it throws a NullPointerException.

I am doing a fair amount of guessing here so please include more information.

Rgs,
Andreas
http://www.amundin.com