From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-08-2020 07:28 AM
Hi there,
I'am looking for a way to determine if an Int value exists within a ring tpedef .
As usual there is no simple way to do simple things with labview. Sorry for the sarcasm...
Does anybody knows of vi or process to find out my int value is defined in the ring lists?
Thanks in advance.
Eric
Solved! Go to Solution.
07-08-2020 08:17 AM
@Ericg67 wrote:As usual there is no simple way to do simple things with labview. Sorry for the sarcasm...
Guess that depends on what you call simple...
The hidden scripting property would make it even easier:
Keep in mind that the strings and values are not part of the ring's data type. The ring's data type is simply an U16, the strings and values are properties! So making it a type def won't update the strings and values of all type def instances.
In short, making a ring a type def seems pretty redundant to me...
07-08-2020 08:20 AM
Menu rings have a property called "Strings And Values[]". You can search values within that array of clusters to find the values that are already defined.
07-16-2020 03:22 AM
Hi wiebe ,
Thank you for your answer.
So what i meant with " simple way" was an equivalent to "Enum.IsDefined" in C# ..... Not requiring the user to reacreate a whole loop or checks from the scratch. As ring and enum are used widely enough in labview, one would think that such a function is already available.
Basicaly, the Ring in our application is used as an array of commands IDs for a communication interface, in order to avoid having to deal with hex data directly. We use ring as enum doesn't allow for non-consecutive/custom values without having to define /disable all the values not used between 0 and your max value.
When a command comes in, we basically need to check if that a command ID is an authorised/ existing one within our ring definition. That's where an existance check is useful to either accept or discard the command.
I'll give your scripting answer a go and see how it works.
Thanks
07-16-2020 03:25 AM
Hi Eric,
@Ericg67 wrote:
Not requiring the user to reacreate a whole loop or checks from the scratch. As ring and enum are used widely enough in labview, one would think that such a function is already available.
Basicaly, the Ring in our application is used as an array of commands IDs for a communication interface, in order to avoid having to deal with hex data directly.
In your case the ring is filled with values either once manually at VI edit time or with each VI run programmatically at runtime. In both cases you know the available IDs (aka integer values) and can implement that check loop easily…
(THINK DATAFLOW: there is a data source (of your integer values) and you want to check user input against that data source.)
07-16-2020 07:10 AM
wiebe@CARYA wrote:
Keep in mind that the strings and values are not part of the ring's data type. The ring's data type is simply an U16, the strings and values are properties! So making it a type def won't update the strings and values of all type def instances.
In short, making a ring a type def seems pretty redundant to me...
Yes, but ... if you make a Strict typedef of a ring, then changes to strings and values in the strict typedef will propagate to the instances that are controls/indicators; but will not propagate to instances that are constants ...
unless:
07-16-2020 07:32 AM
@Ericg67 wrote:
So what i meant with " simple way" was an equivalent to "Enum.IsDefined" in C# .....
But an enum is not the same as a ring at all. A ring's values are subject to change at run-time, not so for an enum. There is most likely a way to get an enum check up and running so that it is constant-folded in LabVIEW which will, for all intents and purposes, achieve what you want.