home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
tutor
/
l3p150
< prev
next >
Wrap
Text File
|
1990-07-15
|
3KB
|
77 lines
╔════════════════════════════════════════════════════╗
║ Lesson 3 Part 150 F-PC 3.5 Tutorial by Jack Brown ║
╚════════════════════════════════════════════════════╝
\ Here is another way to write SPEED_CHECK . This time the messages
\ are built into the speed interval words. This factoring has the
\ disadvantage that all intervals are checked even when one of the
\ one the very_slow message has been printed. There would be no
\ advantage to changing the order of the lines in the word
\ SPEED_CHECK as every interval would be checked anyway!
\ Message Speed range kmph
\ ----------- ------------------
\ " issue ticket, impeding traffic flow." 0 - 15
\ " issue warning, impeding traffic flow." 16 - 30
\ " no action, safe speed." 31 - 55
\ " issue warning, exceeding speed limit." 56 - 65
\ " issue ticket, exceeding speed limit." 66 - 99
\ " arrest motorist, dangerous driving." 100 -
\ Display ticket msg ifis speed is very slow 0 - 15 kmph
: VERY_SLOW? ( speed --)
0 15 [IN]
IF ." Issue ticket, impeding traffic flow."
THEN ;
\ Display warning msg if speed is slow 16 - 30 kmph
: SLOW? ( speed --)
16 30 [IN]
IF ." Issue warning, impeding traffic flow."
THEN ;
\ Display no action msg if speed is normal 31 - 55 kmph
: NORMAL? ( speed --)
31 55 [IN]
IF ." No action, safe speed."
THEN ;
\ Display warning msg if speed is fast 56 - 65 kmph
: FAST? ( speed --)
56 65 [IN]
IF ." Issue warning, exceeding speed limit."
THEN ;
\ Display ticket msg if spped is very fast 66- 99 kmph
: VERY_FAST? ( speed --)
66 99 [IN]
IF ." Issue ticket, exceeding speed limit."
THEN ;
\ Display arrest msg if speed is dangerous 100 kmph and over.
: DANGEROUS? ( speed -- )
100 200 [IN]
IF ." Arrest motorist, dangerous driving."
THEN ;
\ Display broken msg if speed is invalid, negative or > 200 kmph.
: BROKEN? ( speed -- )
DUP 0< SWAP 200 > OR
IF ." Super-F Radar Gun is broken"
THEN ;
\ Check speed and print appropriate message.
: SPEED_CHECK ( speed -- )
DUP VERY_SLOW?
DUP SLOW?
DUP NORMAL?
DUP FAST?
DUP VERY_FAST?
DUP DANGEROUS?
DUP BROKEN?
DROP ;