09-06-2023 12:48 AM
I need to customize the Enum's values with string. but by default, it is Numeric but i need to have string in place of numeric in values
09-06-2023 01:38 AM - edited 09-06-2023 01:39 AM
09-06-2023 02:13 AM
I'm not sure Gerd's solution is what you were looking for. On first read I thought it was what you look for but I think you look more for something like the Combo Box. If you disable "Allow Undefined Strings" it very much behaves like an enum.
09-06-2023 02:50 AM
A Enumeration is always a "named numeric list". If you want the text from an Enum, use Format into string, if you want a list of strings, use Combo box or ring control.
09-06-2023 02:51 AM - edited 09-06-2023 02:53 AM
A ring allows run time editing of strings too.
You can actually edit an enum's strings (even in an exe IIRC), but only if the control is idle (either a ctl that's not in a running VI or a control on a VI that's not running). So that significantly narrows down the usefulness of this (to cases where a combobox or ring are more practical)...
If you want the strings of an enum (often), I'd modify a copy of Enum to Array of Enums.vim to Enum to Array of String.vim:
Every now and then a right click menu can be used, as a menu has the same look as an enum. You can catch the mouse down? event, and if it's a left click change it to a right click. Now every control can have enum-ish behavior. Of course you'd need to catch the menu selection event. The menu can be stored in the control, and optionally be modified in the menu activation event.
09-06-2023 04:23 AM
@wiebe Why so advanced?
09-06-2023 04:57 AM - edited 09-06-2023 05:09 AM
@Yamaeda wrote:
@wiebe Why so advanced?
Because going over variants will make things terribly slow. Relatively anyway.
Converting to variant is slow, but those variant type VIs have 1 or more CLFN, slowing down things even more.
The .vim code might actually be constant folded, resulting in 0 overhead during execution. This would make it as fast as a string array constant.
EDIT:
Note that the .vim executes 50M times (vs 50K) and is still 40% faster.
09-06-2023 08:31 AM
wiebe@CARYA wrote:
Note that the .vim executes 50M times (vs 50K) and is still 40% faster.
Dayum! That's a big difference! Though if performance is an issue i guess you can do something with First call and caching.
09-07-2023 03:12 AM
@Yamaeda wrote:
wiebe@CARYA wrote:
Note that the .vim executes 50M times (vs 50K) and is still 40% faster.
Dayum! That's a big difference! Though if performance is an issue i guess you can do something with First call and caching.
Or make the .vim 😄.