home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / state < prev    next >
Text File  |  2020-01-01  |  1KB  |  40 lines

  1. ; From: Dat Thuc Nguyen
  2. ; URL: http://www.smalltickle.com
  3. ;
  4. ; The state machine is a useful concept in many applications.
  5. ; The following script suggests a framework for a state machine.
  6. ;
  7. ; Replace the ECHO statements with the desired functionality
  8. ; for each state.  Note that normally an "input" would be
  9. ; provided as an argument to each state_xxxx macro to allow it
  10. ; to decide whether to change state, and which state to change to.
  11.  
  12. define state_initial {
  13.     echo This is the \m(state) state.
  14.     .state = warmup
  15.     echo The next state is \m(state).
  16. }
  17.  
  18. define state_warmup {
  19.     echo This is the \m(state) state.
  20.     .state = running
  21.     echo The next state is \m(state).
  22. }
  23.  
  24. define state_running {
  25.     echo This is the \m(state) state.
  26.     .state = slowdown
  27.     echo The next state is \m(state).
  28. }
  29.  
  30. define state_slowdown {
  31.     echo This is the \m(state) state.
  32.     .state = stop
  33.     echo The next state is \m(state).
  34. }
  35.  
  36. .state = initial
  37. while not equal \m(state) stop { state_\m(state) }
  38.  
  39. END
  40.