Jump to content

Finite state machine: Difference between revisions

m
→‎{{header|REXX}}: added commentary annotation to the output (showing the user "inputs").
m (→‎{{header|REXX}}: finished editing the REXX entry, hit SAVE instead of PREVIEW.)
m (→‎{{header|REXX}}: added commentary annotation to the output (showing the user "inputs").)
Line 474:
{{trans|BASIC}}
 
<br>This is almostessentially a one-for-one translate of the '''BASIC''' program, with the following differences:
::* the input allowed is either the uppercase or lowercase version of the letter(s)
::* a mixture of uppercase and lowercase letterstext areis used for the output messages
::* messages have extra blanks for readability &nbsp; (and options are spelled out)
<lang rexx>/*REXX pgm simulates a FSM (Finite State Machine), input is recognized by pressing keys.*/
10: say "pressPress D (deposit) or Q (quit)" /*display a prompt (message) to term. */
20: $=inkey(); upper $ /*since this a terminal, uppercase KEY.*/
if $=="D" then signal 50 /*Is response a "D" ? Process deposit.*/
Line 501:
140: say "Refunded" /*display what action just happened. */
signal 10 /*go & re-start process (ready state). */</lang>
{{out|output|text= &nbsp; when using (pressing) the exact same input(s) as the '''BASIC''' entry: &nbsp; &nbsp; <tt> D &nbsp; R &nbsp; D &nbsp; S &nbsp; R &nbsp; Q </tt>}}
<pre>
press D (deposit) or Q (quit)
d ◄■■■■■■■■■■ user pressed this key.
Press S (select) or R (refund)
r ◄■■■■■■■■■■ user pressed this key.
r
Refunded
press D (deposit) or Q (quit)
d ◄■■■■■■■■■■ user pressed this key.
d
Press S (select) or R (refund)
s ◄■■■■■■■■■■ user pressed this key.
s
Dispensed
Press R (remove)
r ◄■■■■■■■■■■ user pressed this key.
r
press D (deposit) or Q (quit)
q ◄■■■■■■■■■■ user pressed this key.
a
</pre>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.