07-22-2013 09:01 AM - edited 07-22-2013 09:01 AM
I am trying to extract the individual elements from the Ctrl Vals Invoke Node.
The front panel of the VI being called has a string and 4 doubles:
I am calling the VI and trying to read the values like so:
The error I get is:
Could someone please explain what I am doing wrong here? I just want to extact the 5 variables from the VI front panel (string and 4 doubles). I attempt to extract it as a cluster only because the Context Help mentions the Variant Data is a cluster. I would ideally unbundle this as well, but I can't even get the cluster yet.
The code is also incredibly straight forward, so I didn't attach the VI. If anyone wants the acutal VI, I can attach it to a future post. All I am doing is calling two Invoke Nodes to run then get the values of the front panel. And lastly trying to extract the variables from the Variant Data.
Solved! Go to Solution.
07-22-2013 09:25 AM
The datatype of 'Ctrl val.Get all' is an array of clusters containing ctrl name (string) and ctrl value (variant).
You cannot (AFAIK) convert this data directly to a cluster of string and doubles.
Are the names (labels) and datatypes of the called VI's controls fixed and known? If they are, you can select each one by name and convert it to the correct datatype.
I once stumbled upon a VI (from openG, I believe) that would get the datatype of a variant, but I can't find it right now...
07-22-2013 09:30 AM
@Pianne wrote:
The datatype of 'Ctrl val.Get all' is an array of clusters containing ctrl name (string) and ctrl value (variant).
You cannot (AFAIK) convert this data directly to a cluster of string and doubles.
Are the names (labels) and datatypes of the called VI's controls fixed and known? If they are, you can select each one by name and convert it to the correct datatype.
I once stumbled upon a VI (from openG, I believe) that would get the datatype of a variant, but I can't find it right now...
Pianne had the right approach. After indexing it as an array and then unbundling the clusters I was able to come up with a valid solution:
Thanks for the help!
07-22-2013 09:30 AM
One Image speak more than thousand of words 😄
Ctrl Vals Invoke Node Datatype = 1D Array of Cluster (String and Variant). Ur typecast never will work :[
07-22-2013 09:32 AM - edited 07-22-2013 09:33 AM
@TimeWaveZero wrote:
One Image speak more than thousand of words 😄
*removed image for space*
Ctrl Vals Invoke Node Datatype = 1D Array of Cluster (String and Variant). Ur typecast never will work :[
I tried this approach too, but it gave me issues because I had a mix of strings and doubles. It crashed in the for loop since not all of them were strings. (Perhaps I had a different error if you tested this otherwise? I went with the approach above since the for loop gave me problems.)
I think this is very helpful for learning the right approach, but it isn't exactly suitable since I had mixed data types.
Thanks though 😄
07-22-2013 09:32 AM
07-22-2013 10:13 AM
Some Dirt Approach (i'm going to work right now) with different Datatypes,as mentioned in other posts:
Use Variant to Flattened String Function to Retrieve the Type Information (Actually 1D Array of I16), index and then, put some comparison where every case represent
one datatype. 😄