Thread: pbasic question
View Single Post
  #13   Spotlight this post!  
Unread 15-01-2003, 01:00
Don Reid Don Reid is offline
Registered User
#0997
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Corvallis, Oregon
Posts: 45
Don Reid will become famous soon enough
Loops, GoTos, states

What is needed for this is called a state machine.

The code goes through the main loop many times and does different things each times. Some information about the state of the system is kept from loop to loop (in variables).

There should only be one SERIN/SEROUT set in the loop.

The example posted with the SELECT command uses the counter variable as the only state. More complex machines can use additional state variables.

Flow charts are commonly used to understand the workings of state machines.

There are no gotos in the example because the SELECT-CASE command implies them for you (like IF-THEN-ELSE). Both are new with PB2.5.
__________________
Don Reid