1 \ @(#) misc1.fth 98/01/26 1.2
\r
2 \ miscellaneous words
\r
5 \ Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
\r
7 \ The pForth software code is dedicated to the public domain,
\r
8 \ and any third party may reproduce, distribute and modify
\r
9 \ the pForth software code or any derivative works thereof
\r
10 \ without any compensation or license. The pForth software
\r
11 \ code is provided on an "as is" basis without any warranty
\r
12 \ of any kind, including, without limitation, the implied
\r
13 \ warranties of merchantability and fitness for a particular
\r
14 \ purpose and their equivalents under the laws of any jurisdiction.
\r
22 : (WARNING") ( flag $message -- )
\r
29 : WARNING" ( flag <message> -- , print warning if true. )
\r
30 [compile] " ( compile message )
\r
32 IF compile (warning")
\r
37 : (ABORT") ( flag $message -- )
\r
46 : ABORT" ( flag <message> -- , print warning if true. )
\r
47 [compile] " ( compile message )
\r
55 : ?PAUSE ( -- , Pause if key hit. )
\r
57 IF key drop cr ." Hit space to continue, any other key to abort:"
\r
58 key dup emit BL = not abort" Terminated"
\r
64 : CR? ( -- , do CR if near end )
\r
65 OUT @ #cols 16 - 10 max >
\r
70 : CLS ( -- clear screen )
\r
73 : PAGE ( -- , clear screen, compatible with Brodie )
\r
77 : $ ( <number> -- N , convert next number as hex )
\r
79 bl lword number? num_type_single = not
\r
80 abort" Not a single number!"
\r
83 IF [compile] literal
\r
94 variable TAB-WIDTH 8 TAB-WIDTH !
\r
95 : TAB ( -- , tab over to next stop )
\r
96 out @ tab-width @ mod
\r
97 tab-width @ swap - spaces
\r
100 \ Vocabulary listing
\r
104 WHILE dup id. tab cr? ?pause
\r
113 variable CLOSEST-NFA
\r
114 variable CLOSEST-XT
\r
116 : >NAME ( xt -- nfa , scans dictionary for closest nfa, SLOW! )
\r
121 IF ( -- addr nfa ) 2dup name> ( addr nfa addr xt ) <
\r
122 IF true ( addr below this cfa, can't be it)
\r
123 ELSE ( -- addr nfa )
\r
124 2dup name> ( addr nfa addr xt ) =
\r
125 IF ( found it ! ) dup closest-nfa ! false
\r
126 ELSE dup name> closest-xt @ >
\r
127 IF dup closest-nfa ! dup name> closest-xt !
\r
136 REPEAT ( -- cfa nfa )
\r
141 : @EXECUTE ( addr -- , execute if non-zero )
\r
147 : TOLOWER ( char -- char_lower )
\r
150 IF ascii A - ascii a +
\r
155 : EVALUATE ( i*x c-addr num -- j*x , evaluate string of Forth )
\r
156 \ save current input state and switch to passed in string
\r
162 \ interpret the string
\r
164 \ restore input state
\r
170 : \S ( -- , comment out rest of file )
\r
173 BEGIN \ using REFILL is safer than popping SOURCE-ID
\r