How do u remove an entry from a structure
So I have a structure, and there are 19 entries. I want to delete 2 of them, and I issues a command:
sCalendar_Anniversary[i] = sClearCalAnniversary;
this will make all the columns within the structure as zero. But these 2 entires are still part of my 19 entries. Is there a command like in java to delete the entries instead of me just zeroing out the columns within the structure?
0
Comments
In NetLinx, a buffer or array length once defined is always reserved in memory.
So in your case, the structure array, once defined with a length of 19, has reserved this memory forever.
volatile _myStruct myStructArray[19] // will have 19 elements of the structure in memory, this is fix reserved
What you can do is to define how much elements of that array should be "operational" by the string and array operators.
set_length_array(myStructArray, 17) // the operative length of the array is now 17
The content of the structure elements 18 and 19 now is still present in memory, but no longer available for any array or string instructions.
Direct access into the memory cells of array elements 18 and 19 is still possible
But though writing data into cells of myArrayStruct[19], the length_array() is still 17
To make them available again for string and array operator, the operative length must be set again to 19
Thanks, that seems to work. It is a convulated way to remove a array entry. In java all u do is do arry.remove(17) but it seems to work, so thanks again, just need to be aware of how many elements will be added to structure as it is dynamic. so every time I want to add an element I have to do this:
1) add one to the array length: if prior length was 17, then new length will be 18
set_length_array(sCalendar_Anniversary, 18);
2) then set the array structure(18) to new value(s) -- in sTmpCalAnniversary
sCalendar_Anniversary[18] = sTmpCalAnniversary;