LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining the variable type

Solved!
Go to solution

Hi everyone,

I guess the subject is a little misleading, but I could not think of anything else to put in the subject box. I have an excel file that contains both string and number. So for example, the file looks like

Name age

x           10

I managed to read the file from labview, and because I know that age is a number, I can convert that to a number from string. But my question is, what if I do not know that age is a number or if there is another column that contains some other information but I do not know whether it is string or number, how do I determine the type from labview?

 

I am using labview 8.0 in windows 10. 

Thanks,

Kaawn

0 Kudos
Message 1 of 6
(3,112 Views)

Hi Kaawn,

 

In practice this should not really happen because you should have a well-defined data format. However it is fun to think about some solutions for it. If the data can only be letters or numbers, but not both, then problem is quite easy. You can search for any digits, 0-9, and if they exist it's a number. If the data can be mixed, like a username, then it can get trickier.

Capture.PNG

0 Kudos
Message 2 of 6
(3,101 Views)

It only matters if the number actually means something and the numeric value is actually used later for some calculations. if not, just read and display everything as a string.

 

In the most general case, there is no way to tell the difference. It could be many things (integer, floating point, timestamp, path, string, etc.).

 

If this is a real Excel file, maybe there is a way to read out the field formatting?

 

0 Kudos
Message 3 of 6
(3,075 Views)

Hi Gregory,

Yes that helps, but what if my data is mixed like lets say unit2. How would I do it in this case?

 

Thanks,

Kaawn

0 Kudos
Message 4 of 6
(3,039 Views)

@kaawn wrote:

Yes that helps, but what if my data is mixed like lets say unit2. How would I do it in this case?


 

What is "it" that you want to do? You want the number 2, the string "unit2", or something else?

Gregory already gave you a mixed case (LabVIEW2019).

0 Kudos
Message 5 of 6
(3,024 Views)
Solution
Accepted by kaawn

If it's exactly like that, you could do it like my third example. 

 

Capture.PNG

0 Kudos
Message 6 of 6
(3,022 Views)