LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to include enums in ini file?

I am writing a new ini file and i want to include an equivalent of enums in my ini file. 

For example:

enum Fault(0="Inactive", 1="Active", 3="Latched") where Fault is a 2 bit data. This 'Fault' i will then be using as a 'SignalType' instead of 'Int'. As a result when i view the result of a fault, i need the value to be displayed as 'Inactive' or 'Active' or 'Latched' instead of 0,1 or 3.

Is this possible or will i only get 0,1 or 2 and i will have to interpret the values myself?

0 Kudos
Message 1 of 8
(5,313 Views)

@PoonamA wrote:

I am writing a new ini file and i want to include an equivalent of enums in my ini file. 

For example:

enum Fault(0="Inactive", 1="Active", 3="Latched") where Fault is a 2 bit data. This 'Fault' i will then be using as a 'SignalType' instead of 'Int'. As a result when i view the result of a fault, i need the value to be displayed as 'Inactive' or 'Active' or 'Latched' instead of 0,1 or 3.

Is this possible or will i only get 0,1 or 2 and i will have to interpret the values myself?


I don't understand how this has anything to do with LabVIEW.  Perhaps if you explained why you feel this needs to be in an ini file and not in the code itself, we could better help you?

 

To me, something like this is not likely to have different values in different applications, so it would be something I would not put in an ini file.  If the definition needs to be consistent across your apps, maybe it should be an typedef'd enum in a library.  That way if you change the typedef, all the copies get updated as well.  (And if you did your coding correctly, your code would break in all the places you where you need to update your code and auto-update where you don't, eliminating guesswork.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 8
(5,277 Views)

Have you tried using the OpenG Variant Config Tools?  They work with enums.

0 Kudos
Message 3 of 8
(5,245 Views)

Thank you for the reply, but i think i was not clear in stating the problem or maybe i posted this doubt in the wrong forum.

I will be importing ini files in Teststand and these ini files contains definitions of CAN messages. I just wanted to know if there is any equivalent of 'Enum' which can be used in writing ini file, and if there is, how to use it?

0 Kudos
Message 4 of 8
(5,237 Views)

I'm not sure with TestStand, but in LabVIEW, I just use the string equivalent in the ini files.  I then read the key as a string and use Scan From String to get the enum.

 

You could make a VI to read the ini file and output the values to TestStand.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 8
(5,215 Views)

I see - that was rather dumb of me.  You wanted to store the enum itself, not the values!  I guess that's what I get for patrolling the forums after my bedtime.  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 8
(5,196 Views)

 

take a look at the image.

Capture.PNG

 

good luck.

0 Kudos
Message 7 of 8
(5,173 Views)
Actually when scanning from a string to an enum you need to check both the error AND the remaining string output. With the enumeration shown, "Reading War and Peace" will also give a valid match to "Read".

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 8
(5,106 Views)