- May
- 3,515
- 5
A state transition table is essentially a two-dimensional array of program logic, as shown below. The first column is a list of possible states; each subsequent column is associated with a possible event (though some events may not be possible in all states). Two items are entered in each location where a state intersects with a possible events: 1) the action to be performed, and 2) the next state. This is a representation of the program's logic, particularly useful if each "event" represent a potential next input element.
A potential syntax (pseudocode) is:
The text and drawing below are from the "State Transition Table" topic in Wikipedia
Two-dimensional state tables
State transition tables are typically two-dimensional tables. There are two common forms for arranging them.
Events
State E1 E2 ... En
S1 - Ay/Sj ... -
S2 - - ... Ax/Si
... ... ... ... ...
Sm Az/Sk - ... -
(S: state, E: event, A: action, -: illegal transition)
A potential syntax (pseudocode) is:
Code:
[/FONT][/B][/SIZE]
statetable table_name
state start
event e1
actiona1
next start
event e2
action a2
next middle
event EOF
action report_empty
next table_exit
event default
action report default
state start
state middle
event e2
action a2
next middle
event eof
action report summary
next table_exit
endtable
Two-dimensional state tables
State transition tables are typically two-dimensional tables. There are two common forms for arranging them.
- The vertical (or horizontal) dimension indicates current states, the horizontal (or vertical) dimension indicates events, and the cells (row/column intersections) in the table contain the next state if an event happens (and possibly the action linked to this state transition).
Events
State E1 E2 ... En
S1 - Ay/Sj ... -
S2 - - ... Ax/Si
... ... ... ... ...
Sm Az/Sk - ... -
(S: state, E: event, A: action, -: illegal transition)