12-11-2020 09:25 AM
So I wanted to get an opinion on the robustness of this method of finding the last value of an enum.
I have a basic idea of what the coerce to type does. However, I can't help but get nervous when I test the edges of a function that I don't fully understand what's happening under the hood.
Fun note: If it's a robust concept, it allows you to iterate over every value of an enum.
12-11-2020 10:22 AM - edited 12-11-2020 10:24 AM
@JW-JnJ wrote:Fun note: If it's a robust concept, it allows you to iterate over every value of an enum.
So does Enum to Array of Enums.vim...
Range Limits for Type.vim does most of this. But you still have to convert to I32 and add 1.
As NI uses this exact method (see there vims), I'd say it's the way to do it.
12-11-2020 11:02 AM - edited 12-11-2020 11:09 AM
You might enjoy looking at the Natt Sequence. I'm fairly certain the Enum To Array Of Enums.vim is included in LabVIEW 2020.
EDIT: Yep, that VIM was added in LabVIEW 2020. Look in the Numeric->Conversion palette. Also added was the Range Limits For Type.vim in the Numeric palette.
12-11-2020 12:07 PM - edited 12-11-2020 12:07 PM
@crossrulz wrote:
You might enjoy looking at the Natt Sequence. I'm fairly certain the Enum To Array Of Enums.vim is included in LabVIEW 2020.
EDIT: Yep, that VIM was added in LabVIEW 2020. Look in the Numeric->Conversion palette. Also added was the Range Limits For Type.vim in the Numeric palette.
Cool. I didn't see the range limits vim when I migrated to a newer LabVIEW recently. Also, it seems that range limits vim does the coerce from infinity so I guess it's a viable thing to do. Thanks.
Edit: I JUST migrated to 2020, so I'm still catching up.
12-11-2020 01:12 PM - edited 12-11-2020 01:14 PM
I'll admit the other options laid out here are probably better. But here is the first solution I thought of. It doesn't use VIMs, and so older versions of LabVIEW can do this too.
This function returns all enum values as an array of strings. Using the delete from array will give you the last one. Or if you want it as an enum you can get the size of this array then use coerce to type.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord