04-18-2018 10:57 AM - edited 04-18-2018 10:58 AM
Hi,
I want to compare the output of a VI to a value read from a file. The file is written in with multiple key-value pairs. I want to programmatically make sure that the key matches the Label of the VI so if my VI has "Channel" and "Status" as outputs, I want to compare the output of "Status" from the VI with the value paired with the "Status" key. Is there a way for me to get the label of a VI's connector as a string so I can do a string compare to make sure the VI's connector label is the same as the key?
Thanks
EDIT: I'm using Labiew 2010.
Solved! Go to Solution.
04-18-2018 11:05 AM
I don't think you can do that outside of some VI Scripting stuff that wouldn't work outside of the dev environment.
That said- it sounds like you're trying to enforce that your VI is wired right. If that's the case, what you're doing isn't a good idea as it will only fail at run-time, not edit time. I'd suggest using a typedef'd output, then you won't be able to connect it wrong.
04-18-2018 11:19 AM
Okay, thanks!
My goal is to have one VI that can take in an arbitrary input and then go through an array and choose the correct value.
If I have a file with key-value pairs:
Key1, Value1
Key2, Value2
Key3, Value3
...
I would read that into an array in Labview.
Now I want to take a connection from another VI with a label, such as Key2, and then match that label with the key read in from the file so my VI would match "Key2" from the input file with "Key2" from the label of the input and then output "Value2". I thought that would be an easy way for arbitrary VIs with potentially different label names. Perhaps I need to approach this with a different strategy.
04-18-2018 01:49 PM
I think you can use the "Name" output of the "Get type information" on the Variant -> Data type parsing palette to do this.
It extracts whatever the name of the data on the wire was, which is by default the label output indicator it comes from.
04-18-2018 02:00 PM
One method would be to use a typedef'd output and make your multi-use VI polymorphic so it picks the correct version automatically.
04-18-2018 02:06 PM
Try this.
04-18-2018 03:43 PM
@Kyle97330 wrote:
I think you can use the "Name" output of the "Get type information" on the Variant -> Data type parsing palette to do this.
It extracts whatever the name of the data on the wire was, which is by default the label output indicator it comes from.
It doesn't look like there are any default attributes. Based on your comment I would of expected "MyNumber" to be available as an attribute named "Name".
04-18-2018 04:16 PM
None of those are "Get type information". This is:
04-19-2018 02:56 AM
Hi
If I understand the requirement correctly, you would like to run some VIs dynamically and check if the outputs match your expected values.
Could you try as in the attached picture and see if it works?
04-23-2018 08:28 AM
@Kyle97330 wrote:
None of those are "Get type information". This is:
Yes, Thanks! That's exactly what we're looking for!
Unfortunately, I don't think this VI exists in Labview 2010 which is what we're using. We're going to still check for the key and values but we're going to hardcode the key name in the VI where we would have used the Get Type Information VI