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