NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Active Participant
jyang72211
Posts: 1,323
0 Kudos

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!
Knight of NI
Posts: 18,064

Re: Making enum with string cases

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. 

Active Participant
jyang72211
Posts: 1,323
0 Kudos

Re: Making enum with string cases

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!
Trusted Enthusiast
crossrulz
Posts: 3,786

Re: Making enum with string cases

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.



Kudos always welcome for helpful posts...Kudos always welcome for any post.
Trusted Enthusiast
rolfk
Posts: 4,056

Re: Making enum with string cases


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. :smileyvery-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
CIT Engineering Netherlands
a division of Test & Measurement Solutions

LabVIEW Champion
Trusted Enthusiast
Darin.K
Posts: 3,359

Re: Making enum with string cases

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....

Trusted Enthusiast
crossrulz
Posts: 3,786

Re: Making enum with string cases


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.



Kudos always welcome for helpful posts...Kudos always welcome for any post.
Active Participant
jyang72211
Posts: 1,323
0 Kudos

Re: Making enum with string cases

haha.  I meant one time during the first development.

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

Kudos and Accepted as Solution are welcome!
Active Participant
jyang72211
Posts: 1,323
0 Kudos

Re: Making enum with string cases

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!
Knight of NI
Knight of NI
Ben
Posts: 16,091

Re: Making enum with string cases


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

 

Ben Rayner
Who is NOT John Galt... yet... just building Rayner's Ridge

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page