mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-17 08:48:06 +11:00
af39b37dd1
This is more than cosmetic, it's also highly usable. The presence or absence of the "ok" message allows us to know whether the command aborted. Previously, the "> " prompt appeared when the system expected a prompt in the INTERPRET context, whether the previous command aborted or not. Also, this allows us to get rid of that ugly FLAGS global variable.
38 lines
750 B
Forth
38 lines
750 B
Forth
( Words allowing printing strings. Require core )
|
|
( This used to be in core, but some drivers providing EMIT
|
|
are much much easier to write with access to core words,
|
|
and these words below need EMIT... )
|
|
|
|
: (print)
|
|
BEGIN
|
|
C@+ ( a+1 c )
|
|
( exit if null )
|
|
DUP NOT IF 2DROP EXIT THEN
|
|
EMIT ( a )
|
|
AGAIN
|
|
;
|
|
|
|
: ."
|
|
34 , ( 34 == litWord )
|
|
BEGIN
|
|
C<
|
|
( 34 is ASCII for " )
|
|
DUP 34 = IF DROP 0 THEN
|
|
DUP C,
|
|
NOT UNTIL
|
|
COMPILE (print)
|
|
; IMMEDIATE
|
|
|
|
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
|
|
|
|
: (uflw) ABORT" stack underflow" ;
|
|
|
|
: BS 8 EMIT ;
|
|
: LF 10 EMIT ;
|
|
: CR 13 EMIT ;
|
|
: CRLF CR LF ;
|
|
: SPC 32 EMIT ;
|
|
|
|
: (wnf) (print) SPC ABORT" word not found" ;
|
|
: (ok) SPC ." ok" CRLF ;
|