Showing results for 
Search instead for 
Did you mean: 

How can I convert data in string into all available data types in Labview?

Go to solution

: I do not need it for real time. I just wanted an array of string (having different type of values) that can be converted into various data types maintaining the same value.


The above suggestions helped me to get almost all the data types from string as input. If I will find any problem further, I will buzz again.


Thanks muks, altenbach and smercurio_fc.

0 Kudos
Message 11 of 16

I am tryning to make a Subvi that has one output reconstructing of any selected control at top level  both the data type and the front panel control type (strict). While passing on references of top level controls to subvi's the datatype and the front panel control type are lost. These can be retrieved at runtime, but it seems hard to reconstruct them them at runtime at a lower level using only this reference. The point is, that it is a lot of work to copy and store these properties for all controls separately. The controls are there and fixed. I expect that at least in edit mode labview should be able to have a stealthy peek at what data type and front panel control type (will?) belong to the seleted reference and present the right data type at the output.

Yes. There are hings like typecast,unflatten, select function, case structure and polymorhic vi.

They all share the fact that the datatype to be casted cannot be selected programmatically. By e.g. a refnum. I see Stephen Mercer and Steven Rogers of NI filed a patent doing something like that in 2005. Is that going to lead us somewhere soon ?



0 Kudos
Message 12 of 16

Depending on what your actual question is, you might have picked the perfect time to ask.


My guess is that you're referring to when you pass a refnum to a SubVI and the subvi's input control is not a strict reference. In this case, even when the refnum that you wire from the top level VI is strict, the SubVI doesn't have that information. 


To work around this in LV2016 and older, you should make the control on the SubVI a strict refnum. You can do this by dragging a reference from the parent VI to the SubVI front panel. 


In 2017, you can instead make use of a malleable VI. The aforementioned Stephen Mercer (Aristos Queue) gave a presentation on malleable VIs at NIWeek just last month. Here, among many other things, you can take actions on a refnum that require it to be of a specific type, even without the sub VIM (different extension) knowing the exact type when you write the vim. When you wire the main vi's control's reference to the subvim, the reference will take the appropriate form if it can make the code work. If the code you wrote in the vim will not work with the input you wire, then you'll get a broken run arrow. 

0 Kudos
Message 13 of 16

@cbutcher wrote:



To work around this in LV2016 and older, you should make the control on the SubVI a strict refnum. You can do this by dragging a reference from the parent VI to the SubVI front panel. 



Quoting from Dennis' Ten Commandments found here ...


"Remember the type def, to keep it strict."


When I am faced with having to interact with e control on the FP from a sub-VI, I will often bundle the strict reference into a cluster so that the sub-VI knows the exact data type of the FP object. I wrote about that many times including a recent thread found here.


I also have a gallery of related images that can be found here with the name of GUI controller that contains this image.



That image was mentioned in this thread.


Now if you decide that approach is not viable and you really have to start with a generic control ref...


take a look at this Nugget I wrote back in LV 8.x which start basic and works up to clusters of arrays of clusters of arrays...


I included sample code with that Nugget that showed how to save/restore an arbitrary cluster to/from a config file.





Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 16

dear c.Butcher,

Thank you for the positive news. I understand my endeavours have been surpassed.

I am looking forward to Labview 2017, solving the general reference and datatype conservation issue.

I have been dreaming of a solution that also restores the typedef. Not very succesfull as you can imagine. I surrender. It was not going anywhere anyway. Nevertheless I would like to share my project here, because there might still be some ideas in it that you might like.


Best regards, LV-warrior

0 Kudos
Message 15 of 16

Storing the strict type def for all controls works, but it takes a lot of time.

For each project again. It is boring.

That is why it should be automated.

0 Kudos
Message 16 of 16