LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Table control with different data types

It doesn't look like this is currently possible, but I figured I'd ask anyway. I am using a table control to provide users with the ability to edit and convert data. A lot of the functions requie the data in a numerical format.  I have workarounds, but I'm not exactly happy with them.

0 Kudos
Message 1 of 13
(5,973 Views)

You can make it look like a table has different data types in different columns with a little bit of effort. I posted an example of this: http://forums.ni.com/t5/LabVIEW/array-of-cluster/m-p/1822451#M625032

I recently revisited that code in a newer version of LabVIEW and found that the tab key didn't work quite right due to changes in event handling between LabVIEW versions, so you might have to make some adjustments, but it demonstrates the idea.

0 Kudos
Message 2 of 13
(5,957 Views)

Interesting code 🙂  It doesn't really help me at all though.  My problem is that I don't want to introduce rounding errors in converting between %s and %f all the time. The data needs to actually be stored in the memory as a number.

 

I'm currently keeping a "duplicate" %f array of data in the memory and using that for calculations, and the table for display.  Now that I am half way through the program, I have realized that it is becoming increasingly cumbersome. I could have used an object and bundled the table data and array data together, but doing that now would be... effort 😛

 

-M

0 Kudos
Message 3 of 13
(5,948 Views)

A table is just a user interface for an array, and arrays have to contain elements all of the same data type. Now, as nathand said, you could use clusters for your overarching "data type", but you can't go mixing naked doubles, singles, and integers in an array.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 4 of 13
(5,943 Views)

...

I realize that a table is just an array. I just want the data type of that array to be floating point, not string. I don't need mixed data, or clusters, or text rings. I need the visual display capability of a table with the data stored in memory as floating point.

 

-M

 

Edit: To make this clear, I really do realize this very likely isn't possible. It is in CVI, but not LabVIEW.  I wasn't looking for a solution, I was just verifying that I wasn't missing something 🙂

0 Kudos
Message 5 of 13
(5,938 Views)

Pardon me, I might be just seeing this too naively, but if you used the Double default format for your string->number conversion, you wouldn't get rounding errors until the 15th significant figure. And converting to an Extended number should make the conversion even more precise. I can't make the conversion give me any rounding error at all unless the 16th and 17th digits are "50". Are your users going to want to type in that many digits (I know mine won't)?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 6 of 13
(5,928 Views)

You are absolutely correct. This is getting in to "I have a solution but I'm not happy with it".  There were two options to deal with the string data type. Option 1 was keep it in memory twice: once as dbl and once as string with precision 2, simply for display. Option 2 was continually convert back and forth.

 

With option 2, the problem is setting the precision when going from dbl -> string. If I set 15 point precision, the user has to look at 1.143000000000000 for every cell that doesn't have more significant figures, as well as a whole bunch of wasted memory. I can of course make it "smart" by scanning each cell for the decimal place and programmatically setting the floating point for each cell, but that is extra string processing, and still the extra wasted memory.

 

I do realize that for most applications these wouldn't be considerations. Unfortunately, I am working with (some) older computers combined with the rare data sets that will be large enough to want to take memory restrictions in to consideration.

 

Edit: Clarity

0 Kudos
Message 7 of 13
(5,920 Views)
What feature of the table are you using that s normal numeric 2D array indicator does not provide?
0 Kudos
Message 8 of 13
(5,915 Views)

Hi Bowen,

 

number to string conversion, just slighty advanced:

check.png

You see: even with 15 digits precision no trailing zeros…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 13
(5,907 Views)

@Dennis_Knutson wrote:
What feature of the table are you using that s normal numeric 2D array indicator does not provide?

Lots.  Headers, selecting multiple columns/rows. Easily deleting columns and rows. Copying / pasting sections of the data... etc.  Oh, and array indicators are ugly.

Message 10 of 13
(5,906 Views)