08-15-2005 07:55 PM
08-15-2005 10:11 PM
Is this just a learning exercise for state-machines, or are you working towards something. The reason I'm asking is that this type of thing cries out for an event-driven structure. Put your initialization code (if there is still any needed) outside the loop to the left, put an event structure inside the loop instead of the case, and create a value-change event in the event structure for each button. You're done.
No polling for button presses, no shift registers for passing state information. In fact, no overhead of any kind...
08-15-2005 10:23 PM
Excuse me for sticking my oar in here, but given the structure of this example, in what possible way are strings "easier" than enums? But more to the point, ease isn't the issue here. Using a string to carry state information in a situation like this is just plain bad programming practice.
Mike...
08-16-2005 02:44 AM
08-16-2005 11:14 AM
08-16-2005 12:28 PM
tbob,
Much of the hassle you describe with updating all the enum instances will be taken care of auto-magically if you customize the enum as a typedef when you first create it. When you want to add a state, just add it to the customized control, click on File-->Apply Changes, and hey presto! -- all the instances get updated.
I've had some situations where the "grammar" needed to be defined at run-time and enums just weren't feasible (because you can't write to their "strings[]" property). But generally I've come to greatly prefer enums due to a few occasions where I've fed a "quit" to a routine that was looking for "Quit " or "exit".
FWIW,
-Kevin P.
08-16-2005 02:39 PM
08-16-2005 11:02 PM