Download Dimensions

Transcript
I've included three versions of menu
words. Each successive version is more
elaborate and somewhat more difficult
to understand. This progression from
simple to reasonably complete is how I
developed the various ideas. (This code
is available on various RCP/M bulletin
boards. The file MXSET.BLK is a program written in F83 to configure the
Epson printer. Note that it is not a
complete program, but rather a "Study
in Menus." There is also EDITOR.BLK, a
Wordstar-compatible screen editor
that I adapted to F83 from the original
version published by Laxen in Dr.
Dobb's Journal, September 1981.)
Figure one shows the first approach.
It is concerned primarily with display-
.\ Menu support m r d s - Version 2: .A" !ANS
FVD28Apr84
!ANS
(S char -> 1 \ Save allowed response
PAD DUP C@ 1+ 2DUP SWAP C! + C! ; \ Update response list
:
: (.A")
(S
->
+
\ Display =nu item
\ Step p a s t text
EMIT \ Display l e a d char
\ & save a s a l h m e d response
lYPE CR ; \ Display rest
)
CDWT 2DUP
>R
1- StW DUP C@ DUP
!ANS
R>
DASH, FIND
6; ASSOCIATES
." - "
a
1t
(S
: .A"
COMPILE
->
( .A" )
\ Canpile m u item
)
,"
IMMEDIATE
;
O u r company, DASH. F I N D & ASSOCIATES.
is in the business of placing FORTH Programmers in positions su~tedto t h e ~ rcapabllitles.
We deal only with FORTH Programmers
and compan~esusing FORTH. I f you would
like to have your resum& included in our
data base, or i f you are looking for a
FORTH Programmer. contact us or
send your resumt to:
.\ Menu response mrds - (HELP), UKEY
DEFER (HELP)
\ Help word f o r ? response
(S -> A 1
KEY CUP ASCII a ASCII z FEZWEEN
IF ODF AIQ ENDIF
; \ Get upper case key
: UKEY
\ Reference no f o r Help
V?UUABLE HELP#
DASH. FIND di ASSOCIATES
8013 Dalworth. S u ~ t eB
Grand Prairle TX 75050
( 2 1 4 ) 642-5495
AW
Committed t o Excellence
FVD28Apr84
- Version 2: NEW-MENU
FVD28Apr84
(M-STK) OE MJDl' \ Stack of Menu RP@ & SP@
\ The kknu Stack (&SIX) m i n t a i n s exit RP@ & SP@ ad& f o r 6
\ l e v e l s of rnenus. This is used by M-EXIT to a b o r t c u r r e n t m u )
: SIX-MENU
( S -> 1
R> RP@ SP@ (M-SIX) WP @ 2+ + 21 \ RP@ f o r c a l l i n g w3
4 (M-STK) +! >R ;
: USTK-MrmU
( S -> RP@ SP@ )
-4 (M-STK) +! (M-STK) DW @ 2+ + 2@ ;
: NEW-Sm
( S help# -> )
0 PAD !
\ S e t new s e l e c t i o n , not r e t u r n addr
HELP# ! ;
\ S e t help reference
.\ Menu support mrds
VARIABLE
(S help#
: NEW-mu
NEW-SEL
STK-MENU
.\ Menu
->
;
- M-WT - Version
: Em-MENU
USTK-MENU
1
\ Clear screen & v a l i d responses
\ Where to r e t u r n to on Esc
2DROP
;
\
2
E d of m u
FVD29Apr84
- clear
s t a c k item
(S -> )
USTK-MENU Wm RP@ 1 ABORT" Wlg in unstacking menus"
U< ABORT" Menu unstack e r r o r "
SP! RP! ;
(S exit c u r r e n t =nu & r e t u r n to c a l l i n g l e v e l m u )
: M-EXIT
\ Note - Should work but does not.
FORTH Dimensions
16
Continued
Volume VII. No. 2