06-19-2020 05:07 PM
I have a piece of data that is a 1D array where the array element is a variant of an enum.
How do I convert this to an array where the array element is the enum, not a variant?
The only access I have to the enum properties are through the variant of the enum.
I can't just drop a constant on the block diagram and wire it to the Variant to Data VI.
Getting just the numeric values, or converting them to the string values is not enough.
I need the data type of the array element to match the original enum.
Thanks
Solved! Go to Solution.
06-19-2020 05:11 PM
AFAIK, enums are defined at edit-time, not compile time, so you can't "make a new enum" on-the-fly like you're trying to do. You can probably make a ring though. Would that work? What exactly are you trying to achieve?
06-20-2020 03:29 AM
This is the "safe" way to do it. I don't know if you can directly convert an array of variants into an array of enums.
06-20-2020 05:22 AM - edited 06-20-2020 05:25 AM
@BrittonB wrote:
The only access I have to the enum properties are through the variant of the enum.
I can't just drop a constant on the block diagram and wire it to the Variant to Data VI.
Getting just the numeric values, or converting them to the string values is not enough.
I need the data type of the array element to match the original enum.
I suppose, you are looking for the now deprecated
"..National Instruments\LabVIEW 2019\vi.lib\Utility\GetTyp.llb"
this .llb can be used like shown in the following example from this source
"GetTypeInfo.vi"and "GetNumericInfo.vi" can be replaced by the counterpart of the Data Type Parsing VIs
06-20-2020 11:09 AM - edited 06-20-2020 11:16 AM
@alexderjuengere wrote:
@BrittonB wrote:
The only access I have to the enum properties are through the variant of the enum.
I can't just drop a constant on the block diagram and wire it to the Variant to Data VI.
Getting just the numeric values, or converting them to the string values is not enough.
I need the data type of the array element to match the original enum.
I suppose, you are looking for the now deprecated
"..National Instruments\LabVIEW 2019\vi.lib\Utility\GetTyp.llb"
this .llb can be used like shown in the following example from this source
"GetTypeInfo.vi"and "GetNumericInfo.vi" can be replaced by the counterpart of the Data Type Parsing VIs
I don't think they are deprecated. They are there in LV 2020. I guess I missed the intent of the original post, though?
Edit: Maybe those are old versions of the VIs? There are current VIs with the same name but different icons where you expect them in the palette.
You know, I should just read more carefully.
06-20-2020 11:18 AM
@billko wrote:
I don't think they are deprecated. They are there in LV 2020. I guess I missed the intent of the original post, though?
Edit: Maybe those are old versions of the VIs? There are current VIs with the same name but different icons where you expect them in the palette.
Deprecated doesn't mean they no longer exist or can't be used. It means NI no longer desires for them to be used. That they might be superceded by a newer version. And there is a risk that at some point in the future they will disappear.
The red X on the icon indicates this status.
06-20-2020 12:04 PM
@RavensFan wrote:
@billko wrote:
I don't think they are deprecated. They are there in LV 2020. I guess I missed the intent of the original post, though?
Edit: Maybe those are old versions of the VIs? There are current VIs with the same name but different icons where you expect them in the palette.
Deprecated doesn't mean they no longer exist or can't be used. It means NI no longer desires for them to be used. That they might be superceded by a newer version. And there is a risk that at some point in the future they will disappear.
The red X on the icon indicates this status.
We crossed posts. They are deprecated and replaced by new Vis with the same name, just as he showed - and said. And as you said, also. Which means I didn't read his post correctly.
06-22-2020 11:00 AM
Here is a better explanation of my issue.
The VI requires the OpenG Toolkit to run. It is written in LV2018.
06-22-2020 11:03 AM - edited 06-22-2020 11:16 AM
@BertMcMahan wrote:
AFAIK, enums are defined at edit-time, not compile time, so you can't "make a new enum" on-the-fly like you're trying to do. You can probably make a ring though. Would that work? What exactly are you trying to achieve?
I don't need to define a new enum. I need to set new values in an array of existing enums.
I use a ring control for the user interface, but I need to convert the user input back into the correct enum data type.
I added a VI to this discussion to demonstrate my issue.
Thanks
06-22-2020 11:07 AM - edited 06-22-2020 11:17 AM
@billko wrote:
This is the "safe" way to do it. I don't know if you can directly convert an array of variants into an array of enums.
This is definitely the most straight forward way to fix the issue.
But it would mean that I need to maintain a case structure of all the enums that could possibly fill the array.
Enums are added and subtracted all the time. I do not want to maintain that case structure.
All the data type information I need is carried with the variant, I just don't know how to build the object correctly.
I added a VI to this discussion thread to illustrate my issue more clearly.
Thanks