There are a great many articles on the internet about state machines and some interesting frameworks for implementing them. Here's a few links.
http://en.wikipedia.org/wiki/Finite-state_machine
http://melander.dk/delphi/statemachine/
https://github.com/malcolmgroves/TStateMachine
I hope that this article proves useful. I vaguely recall the first time I tried to use a statemachine... it wasn't a pleasant experience until someone sat me down and gave me a really simply introduction to them... something like this article. Feel free to ask questions etc. in the comments and I'll do my best to answer or point you in the direction of the answer.
Until next time... happy coding

vBulletin Message