From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get datatype from a control in a cluster

Hello,

i want to convert double, string, boolean,..  into strings. this isn't a problem.
but i've got an cluster with controls inside which have different datatypes.

i want to convert the values from the controls into string.
My idea is that i can take a case structure with cases for each datatype and convert the data to string inside the case.
does anyone has an idea how to get the datatype from the control?

markus
0 Kudos
Message 1 of 5
(2,430 Views)

Is this for a specific cluster or do you want to make a generic toString function?  for a specific cluster I would suggest unbundeling by name and typecasting to string and append or just use a string formatter.  For a generic solution you could make the cluster an array and then for each item in a loop typecast or format the element to a string and append using a shift register.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 5
(2,425 Views)

I forgot the data type if you stick to your original solution is to use the property node (GObject) has a classID interger value specifying the type.  There are vary many types in labview so I dont use case structures with data types often.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 5
(2,423 Views)

"solution is to use the property node (GObject) has a classID interger value specifying the type."

That works right up till you have a complex cluster of clusters or an array of clusters.

At that point you will have to resort to "trial and error" using the "to more specific" node and monitoring the returned error cluster.

But even this approach requires  the code "know" about every cluster type so it has an associated property node.

Another approach use the "flatten to string" but parses the type descriptor to preceed.

See the LAVA scripting forum for un-supported methods. I have used those techniques to develop LV2 globals given the path to a /ctl of the cluster.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 5
(2,418 Views)
I agree with you Ben.  I just included the classID since it was asked but would avoid this.  It is bes if you need your cluster to be "Serializable" that is the ability to cast it into a string , is to make a function or possibly a polymorphic function for the entire project which will unbundle a specific cluster type (I use/overuse? typedefs ) and then you can have a "String toString(clusterType)" function/subvi that will work throughout and it will adhere with good program modularity, the flatten to string can be the default case if you dont provide this functionality for your specific cluster.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 5
(2,409 Views)