10-27-2016 02:45 AM
Changing data is entered into a 2D array and also displayed in a table. When hour rolls over the 3 columns of data are held and then new row created. Problem is the row moves down but previous data is not stored. I have tried using shift register but that just auto indexs the rows filling array as loop iterates. It looks a really simple basic problem but going around in circles on this one.....
Solved! Go to Solution.
10-27-2016 03:36 AM
You posted a picture of your code, that's not very helpful as I can't run it to see what happens.
Are you just wanting to add data to the bottom of the array (i.e. new rows?). You will definitely need a shift register as you need to store the value of the array between iterations.
You can use either of the following:
(it's a VI snippet, so you can drag it into LabVIEW 2014 or above)
10-27-2016 03:49 AM
Thanks for quick reply, unsure what has happened but it is a code snippet only shown as icon?
I have modifed code to include yours but it auto indexs through the rows,
10-27-2016 03:55 AM - edited 10-27-2016 03:55 AM
What do you mean by 'auto indexs' - you have no auto-indexing terminals?
I really have no idea what you're trying to achieve with this. You initialise the array to a certain size, but then you keep inserting elements (which will make the array grow).
Also, you should use the index *before* your case structure, since the array is 0-indexed. That's why you have the blank row at the top.
10-27-2016 04:07 AM
Using the shift registers increments the rows automatically filling the array.
What I am trying to do is only increment the rows when there is a change of hour. So the active row can have data change during its 'hour' and then on hour rollover the next row is selected with previous retained. I have attached a vi in LV 2014 that shows my earlier code using a case statement. Also a code snippet that still shows as icon?
10-27-2016 04:27 AM
This version now works but is messy..........
10-27-2016 07:49 AM
Hi,
I think what you want to do is move all the code that involves modifying the array into the "True" case of the case structure. This includes the reading of the column values and appending to the array.
See the attached VI.
I've removed the pre-loop initialization of the array as I don't think it's needed. You're just concerned with adding to the end of the array, which just requires the "Build Array" function operating on an initially empty 2-D array.
10-27-2016 08:58 AM
Thanks for reply and vi,
I have tried similar with build array but problem is the data on col 2 to 4 inclusive changes and this has to be displayed as it happens.
With the case structure it can only 'trap' the data and show totals in the 3 columns on hour change not 'live' so to speak.
10-27-2016 09:14 AM
In that case, the "Replace Array Subset" function is what is needed to replace the latest row values with the current values from the user interface.
On time change, an append occurs.
Attached is an update to the VI.
10-27-2016 09:26 AM
That is brilliant and a lot neater than my efforts!!
Thanks Pangvady,
Jack