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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i get from enum items name.

Solved!
Go to solution

Hello,

I have one enum. The enum item names are followed

Pressure1

Pressure2

Pressure3

if i am select pressure1 and enter the values in string control. after taht i am select pressure2 that pressure1 items name is can't display this is a main moto any body help me.

here i am attaching my front panel screen short.

Sivaraj M.S
CLA
0 Kudos
Message 1 of 25
(10,462 Views)

Hi siva,

 

do you want to get the actual string from the enum? Then try the attachment...

Otherwise clarify your question.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 25
(10,446 Views)

siva_usic wrote:

Hello,

I have one enum. The enum item names are followed

Pressure1

Pressure2

Pressure3

if i am select pressure1 and enter the values in string control. after taht i am select pressure2 that pressure1 items name is can't display this is a main moto any body help me.

here i am attaching my front panel screen short.


Hi Siva,

 

your question isn't fully clear, but if I look at the title you want to know the possible string values of an enum?

If that's the case you should download the OpenG toolkit, this usefull set of VIs for all sorts of programming has a special 'enum to strings' VI:

 

What is a 'moto'? and it would help more if you added a screenshot of your code, to do that have a look at the Code Capture Tool it is great for this purpose, you select the part you want to capture, start the tool (Tools->Code Capture Tool), review your setting (FP-none, BD-selected, Clipboard-FileName), finish the capture.
Then you switch over to your internet browser, in the file dialog you past the file name from the clipboard and the file is attached.
To download

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 25
(10,444 Views)

Well, I learn something new every day--I didn't know the Format Into String function behaved this way with enum inputs. I had thought one had to use the "Strings" property, which gives an array of strings that you can use the enum's value to index and thus get its associated string.

 

--Marty

0 Kudos
Message 4 of 25
(10,440 Views)

Hi Marty,

 

well, your approach is maybe faster as you only need to fetch that string array once (as it's constant for an enum). Indexing that array should be faster than formatting strings...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 25
(10,427 Views)

GerdW wrote:

Hi Marty,

 

well, your approach is maybe faster as you only need to fetch that string array once (as it's constant for an enum). Indexing that array should be faster than formatting strings...


However you need a control (or indicator) of that enum, with a property node, causing a thread swap... I think formatting is faster.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 6 of 25
(10,421 Views)

If you have an enum, you have its value, whether it's a constant or a front-panel item--and the value is all you need to get the associated string, just passing the value as input to Format Into String.  Apart from execution speed, that seems like the simplest method, which I will try to use from now on (I can run off and refactor a lot of code now, if I want to 8-).

 

The only time I'd use a property node is if I needed to use it to get other properties. In that case I might as well not add a separate item (Format Into String) to the diagram, but just expand the property node to give me the Strings array.

 

--Marty

Message 7 of 25
(10,417 Views)

Hi TonP,

 

well I wrote "you only need to fetch that array once"! Then all you do is indexing an array... (An enum is constant at runtime, so you really only need to fetch the strings[] once.)

 

See attachment, indexing is ~4 times faster than formatting for me.

Message Edited by GerdW on 12-17-2008 08:36 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 25
(10,397 Views)

I realize execution speed can be important, but most of the time the difference in speed between using a property node and calling Format Into String won't matter at all.  Readability of the code is usually more important, and the Format Into String approach is simpler: one object on the diagram, with one input and one output, rather than a property node with an output that's input in turn to Index Array which itself has two inputs.

 

Thanks for all observations....

 

--Marty

0 Kudos
Message 9 of 25
(10,394 Views)

Hello Gerdw,

                i am leaning from your code. but actually my aim is hide or replace the enum item name. it is possible.

please replay me.

 

Thanks and regards

M.S.Sivaraj

 

Sivaraj M.S
CLA
0 Kudos
Message 10 of 25
(10,365 Views)