LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add an element to a dynamic cluster

Hello all, Newbie here. I have an 1D array of numbers that I am writing to a database and it works fine like this, each element goes in a column.

Screenshot 2023-05-03 083549.png

One problem is that data can change and have different columns, and I don't know how make a changing cluster into a type definition, or if that's possible. Do I need to? I need to add a timestamp to the cluster and tried this but the cluster data shape changes.

 

LabviewScreenshot2.png 

 

Is there a way to add a timestamp element to a 1D array that was converted to a cluster?

0 Kudos
Message 1 of 5
(817 Views)

Clusters always have to be defined before your program runs.

 

You will likely have to switch to a database write VI that is more complicated where you define things more explicitly instead of just the simple "here's a cluster, write it for me" method.

0 Kudos
Message 2 of 5
(813 Views)

So why can't you define it as a 2-D array and have the 1-D array data as one column?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(804 Views)

Thanks for the response Kyle,

I am not very familiar with Labview, I just used the vi that is in the default(I'm assuming) database folder that came with labview 2023. Do you have any suggestions for an alternative? Is there one where I can create the table and define a DateTime field with the default value of system time? Then I won't have to send along a time stamp with the data.

0 Kudos
Message 4 of 5
(775 Views)

Hi Bill,

Thanks for responding. I am not sure I understand your solution. I think that is what is happening now in the second snippet I posted, all the data from the 1D array goes into one column as a single long entry and the time stamp in another column.

I need each piece of data to be in its own column and the timestamp for the record as an additional column. There could be hundreds of columns and it could change at any time. When the column names change or the number of columns changes, the table name also changes and the new table is created as needed.

I could have the timestamp added as the first entry of the array, but it seems Labview won't allow an array to have different data types?

I am always trying to convert solutions from other languages and not sure what's possible in Labview.

0 Kudos
Message 5 of 5
(772 Views)