LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unflatten data using only the output from flatten to string

Using the Unflatten from String vi requires that you provide the type. This is not always possible - you may not know it (or you have a number to choose from). In a situation where the original data is flattened, then the Type String & Data string are clustered & flattened again, you have a common structure no matter what the source data. Unflattening will return the Type & Data strings of the original data, however I have seen no vi anywhere that either converts Type String to Type, or Unflattens data given only the Type & Data strings. How is either of these done?
0 Kudos
Message 1 of 5
(3,401 Views)
Hi cplaw,

I have wanted do this for years. I do not think there is anything availalbe to do what you are asking.

Here is the issue as I see it.

WHAT KIND OF WIRE comes out of this node? The wire type can not be ID'd until the code executes.

THe closest things I can think of that do something close to that or use the type output of the Flatten to string follow.

1)Variant data carries the data type along with the data.

2) If youget a ref to a VI you can do an invoke node that uses the type output of the flatten to string. Note: no output wire.

3) The type descriptor can be parsed to get the strings assosciated with an enum. In this case you get an array of strings.

I am curious about what others have to say on this topic.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(3,400 Views)
Hi Ben,

I think this would require a change to Labview, namely "Polymorphic at Runtime", which would enable a matching vi control type to be selected from a selection of sub vi's.

Can I get some royalties if a future version of Labview uses my idea?

The only practical solution is to include a header that you can use to select from a number of type constants.

Colin.
0 Kudos
Message 3 of 5
(3,400 Views)
Exactly!

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
(3,400 Views)
You are asking too much from LabVIEW or any compiler for that matter. When the the datatype is unknown or undefined at compile time, it can't change the code to adapt to the incoming data. That is the programmer's job to do this and provide code to detect the incoming datatype and branch to appropriate routine to handle each datatype after it has been cast to a known type.

The compiler has to know the datatype before generating the code. Can you imagine executing your diagram in debug mode and see the wire change type from one iteration to the other as the incoming data changes type? That's the programmer that knows what datatypes are to be expected.

The original poster suggested to bundle typestring and flat data: you essentialy have
a structure similar to a variant. If you want to use undefined datatype, you should use variants instead of flattened strings since it includes the datatype. See my presentation on OpenG.org http://openg.org/tiki/tiki-index.php?page=2003-05-06+Group+Meeting
to see how to manipulate variant data at run-time.


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 5
(3,399 Views)