Page 1 of 1

Add new element to an array

Posted: Wed Dec 10, 2014 4:33 pm
by Simon Knight
Hi,

I am attempting to manipulate data stored in a datagrid by accessing the dgdata property. I wish to add a new column/field/element to the data which already has some twenty odd fields. I do this inside a loop that is looping through the numeric keys of an array populated by reading dgdata. My first attempt :

Code: Select all

put "Some data" into tDataA[25]["TheNewElement"]
This does add a new element named 'TheNewElement' but it deletes all of the other elements and becomes the only data. My work around is to read the record into a new record array e.g.

Code: Select all

put tDataA[25] into tRecordA
put "SomeData" into tRecordA["TheNewElement"]
put tRecordA into tDataA[25]
this works but the original column order is lost.

Is there another way of adding an element/column to an array for display in a datagrid that preserves the original column order?

best wishes
Simon

Re: Add new element to an array

Posted: Wed Dec 10, 2014 6:43 pm
by Simon Knight
Odd, but I re-entered my code and it no longer replaces all the other elements.