ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why are there so many types of converters?

Why does LabVIEW have dozens of converters?  Why can't we have a universal converter that you just wire up and it automagically converts the gozinta to the gozoutta?  Well, OK that's asking too much.  But I've got a good start on it.  This XNode (as it's title implies) will convert a string into practically anything.  It adapts to whatever is wired to the output.  (Also, depending on what you've hooked up, there can be an optional "Format" and/or a "Delimiter" input.  But usually the defaults are fine and you don't need to wire these.)

  • Numeric (all representations)
  • Floating point with Units
  • Enum
  • Boolean
  • String (just passes through)
  • Path
  • Array (choice of typecast or convert from spreadsheet string)
  • Cluster (choice of JSON or XML input)
  • TimeStamp

It even handles units:

sud.pngsuf.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 1 of 9
(3,014 Views)

@paul_cardinale wrote:

Why does LabVIEW have dozens of converters?  Why can't we have a universal converter that you just wire up and it automagically converts the gozinta to the gozoutta?:


This old (denied) idea would have dealt with Godzilla instead. 😄

 

Thanks, I'll have a look at your thing!

0 Kudos
Message 2 of 9
(2,991 Views)

@paul_cardinale wrote:

 Why can't we have a universal converter that you just wire up and it automagically converts the gozinta to the gozoutta?   

 

I think "Type Cast" pretty much does that.

 

But I am sure there are some caveats, so use it with caution. 

 

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/type_cast/ 

 

BTW: There are so many converters because there are so many data types and some of us have an "aversion to coercion dots". When I was starting out my mentor called them "loser dots" or "lazy dots".

 

I forgot about the newer "Coerce To Type Function"

 

Similar to Type Cast but works better for numbers.

 

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/coerce_to_type/ 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(2,972 Views)

This is my first attempt at using an Xnode(?) vi?

 

I unzipped everything but opening the top level VI opens it in an empty project and placing it on the block diagram only places an empty vi.

EmptyCapture.PNG

 

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 9
(2,929 Views)

@RTSLVU wrote:

This is my first attempt at using an Xnode(?) vi?

 


Same here. Please include significantly better instructions on how to use all this.

0 Kudos
Message 5 of 9
(2,910 Views)

@RTSLVU wrote:

This is my first attempt at using an Xnode(?) vi?

 

I unzipped everything but opening the top level VI opens it in an empty project and placing it on the block diagram only places an empty vi.

EmptyCapture.PNG

 

 

 


Probably a missing dependency.  I'll submit a fixed version (in a bit,  very busy right now).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 9
(2,896 Views)

The previous version actually works with LV 2018 (which is what I built it with).  But with later versions, one of LV's enums changed, and since I have an overactive aversion to 'Default' cases, there was a case structure that broke.  Here is the fixed version.  Works with LV 2018, 2019, 2020 (of course it you're using 2019 or 2020, you'll get a faster load if you first mass compile).

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 9
(2,885 Views)

Hi Paul,

 

Could you please post in LV2017 version.

0 Kudos
Message 8 of 9
(2,745 Views)

@gkrn wrote:

Hi Paul,

 

Could you please post in LV2017 version.


Here

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 9 of 9
(2,734 Views)