Category : Forth Source Code
Archive   : FIFTH.ZIP
Filename : TEXT.FIV

 
Output of file : TEXT.FIV contained in archive : FIFTH.ZIP
CREATE X
CREATE P
CREATE H
EDIT
variable h
~UP
CREATE PRINT
CREATE BUFFER
EDIT
create buffer 20 1024 * allot
~UP
EDIT
: print
dup @ 77777777 = not \ Check 1st 4 bytes.
abort" Invalid text word " \ Error if not 77777777.
dup 8 + @ swap 4 + @ \ Get length, address.
over 0 do \ For all characters,
dup c@@ buffer i + c! 1+ \ Stack: length address
loop
drop \ Drop the address.
buffer swap h @ \ Stack: buff length handle
write if \ Write out the buffer.
drop \ No error, okay drop.
else
." Write Error" abort \ Otherwise, error!
endif
." <" \ Show something's happening!
;
~UP
CREATE PRINT.ALL
EDIT
: print.all
dup 0= if drop exit endif \ A 0 address says none to print
dup execute print \ Print the current module.
dup child print.all \ Print its children.
next print.all \ Print its brothers.
;
~UP
EDIT
: p

" file.out " 1+ delete \ Delete earlier file.
if else drop endif \ Clean the stack.
" file.out " 1+ 32 createfile \ Create output file.
if
h ! \ Save the handle...
else
." Can't open output file!" \ or bomb if error.
abort
endif
dup execute print \ Print Root of document.
child print.all \ Print the rest...
;
~UP
CREATE |
EDIT
: |
create
77777777 , \ Safety flag.
>in @ , \ Save addr of text stream.
0 \ The count of the bytes.
>in @
begin
dup c@@ \ Is it zero?
while \ While not zero, inc the pointer.
1+ swap 1+ swap \ Increment the counts.
repeat
>in ! \ Point compiler to end of text.
, \ Save the byte count
;
~UP
CREATE DOCUMENT
CREATE CHAPTER1
EDIT
| chapter1

Chapter 1

In this chapter we will explain the
various meanings to life, the universe,
and everything.
~UP
CREATE CHAPTER2
EDIT
| chapter2

Chapter 2

This section is about a young boy,
and his trials in becoming a man.
~UP
CREATE CHAPTER3
EDIT
| chapter3

Chapter 3

Here we give up any pretence of trying
to make sense.
~UP
EDIT
| document

An Example Document
-- ------- --------
~UP
EDIT
\ Running X will print the module named DOCUMENT.
: x ['] document p ;
~UP
ABORT


  3 Responses to “Category : Forth Source Code
Archive   : FIFTH.ZIP
Filename : TEXT.FIV

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/