12-28-2006 03:41 AM
12-28-2006 08:41 AM
A table is just a 2D array of strings, so to do random insertions, your string array needs to be the size of the table from the beginning. Initialize a 2D array of empty strings, then replace elements according to the cell position.
Attached is a simple demo (LabVIEW 8.0) that demonstrates how to fill a table cell whenever a cell is double-clicked. (notice that the table is a disabled indicator, so only programmatic changes can take place). You should be able to modify it for your needs to fill 3 adjacent cells. It may also need a few little tweaks in the coordinate handling.
If you like to fill on a button press, you would sense a single click and place the coordinates into a shift register, later to be read in the "write" event where you do the element replacements. modify as needed. There are many other ways to do this.
Note that all cells have the same size, else the problem would become a bit more complex. 😉
01-01-2007 02:30 AM
01-01-2007 01:32 PM
Well, there are actually reasons for my suggestion. 😄 If performance is an issue, stay away from these nodes. 🙂
In a simple benchmark using a 10x10 table, your invoke node is 18x slower than my version (55 microseconds vs 3 microseconds (actually the array update only takes 100ns (550x faster!) if you don't update the terminal inside the loop e.g. if you need to update several cells at once).
Also, as expected, you still cannot write to cells that are outside the range of the 2D string array of the table.
It is also somewhat dangerous if the table is an indicator as in this case because the rest of the code might not be aware of the new value unless you e.g. resort to reading a local variable of the table. Keeping the table data in a shift register is again more efficient and avoids extra data copies. 😉