labview

Com-interop Enum to Switch Case in LabVIEW


I am using a COM-Interop in LabVIEW, I have some functions that return an enum, I want to make a switch-case structure on this enum but I can't I get a bad wiring error but when I put an indicator to function output I see that the enum returned as expected.

So, my problem is I can't make this switch-case from my enum that exported from interop dll

edited:

I returned the eTestType enum from the node

example of code

labview block


Solution

  • For some reason, your node returns Ring, not Enum data type.

    In LabVIEW, Ring data type consists of string and number value. But string could have any numeric value (they do not necessary go in sequential order). Enum also have string and number value. But, numeric values go in order, starting from 0.

    So one way of you could use your node is to connect ring output to Case Structure, and then use numeric values of your ring as selector. Another way to do it - but just in case if ring values go sequentially, starting from 0 - to create Enum in LabVIEW with the same string value as you expect from your COM-Interop node, and convert Ring values to Enum values. Then, you could use Enum as selector for Case Structure.

    enter image description here

    UPDATE: "Number to Enum.vim" is for LabVIEW 2017 and higher. If you use older versions, then do the following workaround:

    enter image description here

    So you have cluster with enum, and you bundle there ring value. Then when cluster in unbundled, there is enum value.