LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making enum with string cases

I have a case structure with multiple string cases.  Would it be possible to use the info from the case structure to make an enum?  Is there a script out there that can do that?  When I am making a state machine, I like to develop my states first and my my enum later.  It is hard for me to make an enum with all the cases first. What's your preference?

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 26
(2,950 Views)

Did you try a search?

 

Dr. Damien's Development - Creating an Enum from a Text Case Structure

 

I don't understand your statement: "It is hard for me to make an enum with all the cases first". You may not know all the states ahead of time, but I don't understand where the difficulty is. Is it because you are not making the enum a typedef? By making it a typedef you can add/remove states and make sure the case structure stays consistent. 

Message 2 of 26
(2,946 Views)

Sorry, I didn't mean to use the word difficult.  I do use type-def already, but I just find it troublesome to modify the enum multiple of times.  I only want to update it one time.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 26
(2,942 Views)

You should know a large percentage of the cases you need in a state machine before you even start coding.  Therefore the enum should not be changing all that much.  Even so, the enum editor is not that bad.


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
Message 4 of 26
(2,931 Views)

@jyang72211 wrote:

Sorry, I didn't mean to use the word difficult.  I do use type-def already, but I just find it troublesome to modify the enum multiple of times.  I only want to update it one time.


That sounds like you never will modify the software. Smiley Very Happy In my experience that is just wishful thinking. As soon as the application works you or whoever is using your application will come up with new requirements to include.

Rolf Kalbermatter
My Blog
Message 5 of 26
(2,929 Views)

Now if only there was a tool that would let you define the states and the transitions and then create the code for you.  It would be so simple to add, remove and edit transitions.  Nah, that is just crazy talk....

Message 6 of 26
(2,914 Views)

@Darin.K wrote:

Now if only there was a tool that would let you define the states and the transitions and then create the code for you.  It would be so simple to add, remove and edit transitions.  Nah, that is just crazy talk....


Yep, complete crazy talk.


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
Message 7 of 26
(2,893 Views)

haha.  I meant one time during the first development.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 26
(2,851 Views)

At one point, there is a state editor that comes with labview?  I always thought that there is only the separate module.  It will so convenient if they bring the editer back.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 9 of 26
(2,853 Views)

@jyang72211 wrote:

haha.  I meant one time during the first development.


 

I do not have an answer to your posted question but I have to ask out of concern.

 

Are you writing code before you know what the design will be?

 

In my minds eye writing code without a design is like starting a journey without knowing where you are going. Sure it may be a fun adventure but I would be suprised if it result in an efficent path to a solution.

 

Concerned,

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 26
(2,844 Views)