04-06-2016 04:50 AM - edited 04-06-2016 04:53 AM
In the vi above I try to get the number of entries and the string values of an enum type definition. I get error 1057 in the to more specific class vi. Where is my mistake or did I misunderstand something?
Thanks in advance.
Solved! Go to Solution.
04-06-2016 05:11 AM
04-06-2016 07:50 AM
It seems that the static vi ref is incomptible to an G-Object.
The cast to more specific class produces a runtime error, the more generic class an syntax error. If prefer the runtime error since it means that its syntactically correct. It is not working either way.
I believe my idea is fundamental wrong. I want to input something in the class cast vi which allows me to access the "Strings[]" property. This should work somehow since the GObject type numeric exists and has this property.
04-06-2016 08:02 AM
Oh, of course - my bad for not spotting this earlier. You need to create a reference of the control (of the typedef), not of the LabVIEW control file (.ctl).
This should help:
04-06-2016 08:18 AM
Yes, you are right, I did it this way before. But the control has no other use than to provide the object reference. I wanted to do it without control to clean up things a little bit. Your suggestion is a work around, a working one, at least.
In order to maintain the readability of my code I would have to create a control dedicated exclusivly to provide the reference.
04-06-2016 08:40 AM
To be clear, as pointed out the error in the original code is that the reference is to the ctl, which is technically a VI, so if you wanted to get the enum reference, you would need to parse that VI's FP.
You could make Sam's code cleaner by simply creating an implicitly linked to a control, but that would still mean you have a control.
You can also place a constant of the typedef on your BD and feed it into the Get Numeric Information VI from the data parsing palette and that VI has an output with the enum names. That palette should be there in ~2014 and later and the variant VIs should also in vi.lib in earlier versions.
04-07-2016 07:16 AM
Thank you.
I did not want to switch to LV 2015 before the first service pack isn't available.
From your hint I have found a solution: I extract the frontpanel element from the typedef and cast it to enum. It does not look simpler, in fact it is much more complicated, but it seems to me the right way to do it. The attached picture shows an vi, which takes a vi ref of the typedef as input and outputs the strings of the enum defined there. There should be some error handling which I did't do yet, for example to be sure, that the input is a typedef and that it defines an enum, but the principle is there.