11-10-2014 10:30 AM
Hi NI community,
I need your help with deleting the row headers of a table.
The first time the program runs everything is OK.
However, when the user sets a new number of tests and clicks the ‘Run Again’ button the old row headers not only are not being deleted but the new ones are appended under them.
I would like the entire table, headers including, to be deleted and the new results to be displayed starting from the top of the table.
I am attaching a sample program.
Thank you in advance for your help.
Solved! Go to Solution.
11-10-2014 10:58 AM
Here are some ideas (let me preface this by saying I've not worked much with Tables).
1. The Set Cell Value method you are using has been removed in LabVIEW 2012 (and successors), so you may want to consider an alternative.
2. Writing the string "erase" into a cell does not erase the cell, it just makes the cell display "erase".
3. However, writing an empty array into RowHdrs[] may well clear out the row headers.
4. Similarly, wiring an empty 2D array into the Table may well clear out the Table.
5. I'm not 100% certain, but I believe that the Row Headers usually are in Column 1, and the Column Headers are in Row 1 -- be sure not to mix them up.
Note that you should be able to safely do steps 3 and 4 just before you try to "fill" the Table. If you do, then the exact same code should work whether you are filling the table for the first time (when it is already empty) or the 20th time (when there is something to erase).
Bob Schor
11-10-2014 11:38 AM
Hi Bob,
I did not know about the Set Cell Value removal. Thanks for the information.
I replaced it with an empty array but it still does not work.
What troubles me the most is the new headers being appended under the existing ones instead of starting from the beginning. (There is no such problem with the table values, only with the row headers)
Wiring 'erase' was simply for display purposes
11-10-2014 11:54 AM - edited 11-10-2014 12:08 PM
You need to initialize your first shift register )inside the first sequence frame).
Even better, simply use autoindexing to create the array, no shift register needed.
Also note that writing the header does not belong in a loop, writing them once is sufficient. Use the proper datatypes. For example the number of trials is an integer. You have way too many unecessary local variables and sequence structures. most are not needed.
11-10-2014 11:56 AM - edited 11-10-2014 11:58 AM
You have uninitialized shift registers where you're building your row header arrays. This code exists in two places. Why? Regardless, if you initialize your shift registers, Bob will be your uncle.
11-10-2014 11:59 AM
It worked! It worked!
It does exactly what I need.
Thank you very much.
You are the best!!!
11-10-2014 12:11 PM - edited 11-10-2014 12:11 PM
@Broni wrote:
It worked! It worked!
It does exactly what I need.
Thank you very much.
You are the best!!!
I added more information to my answer. Please clean up your code, there is way too much stuff that is incorrect or not needed. For example remove the loops around the header property nodes. Writing once is enough! What good is writing the same property with the same values N times in a row?
11-10-2014 12:51 PM
Thank you for all your recommendations.
I followed them and now the code not only looks much better ... but it works as well.
Thank you!
11-10-2014 12:55 PM - edited 11-10-2014 12:56 PM
If the number of trials is not always an integer multiple of 20, you would make a small modification as follows.
11-10-2014 02:30 PM
The trials must be run in blocks of 20.
If the user’s input is for example 75, then this number is rounded to the closest multiple of 20 that does not exceed the user’s input (60 in this case).
Just out of curiosity, what is the function of the node connected to the remainder? I do not seem to be able to find it in LabView 9.