text
stringlengths
0
99.6k
Which will prevent the count (stored at PAD) from being moved to the variable. However, there is a better solution all together. The solution is to use COUNT. Count takes an address on the stack, and returns the address of the start of the string, and the count byte in the order needed by TYPE. In this version, VITALS remains unchanged (i.e. Just as Brodie gives it in his book), but you will have to replace every occurrence of
<number> -TRAILING TYPE
with the shorter (and faster) phrase
COUNT TYPE
Here is how the beginning of LETTER will look with this second version:
: LETTER PAGE // modification 2
." DEAR " NAME COUNT TYPE ." ,"
CR ." I GO TO HEAVEN WHENEVER I SEE YOUR DEEP "
EYES COUNT TYPE ." EYES. CAN "
and so on. If you try this version, you will notice that it runs much faster, and also occupies less space in the dictionary.
*ln2
Page 276
The version of GREET given here doesn't work because of a rather subtle problem. Remember that '83 Forth uses a count, and not a delimiter to determine the length of the input stream. So in order to get this definition of GREET to work, in '83 Forth, you must do the following:
: GREET83 CR ." WHAT'S YOUR NAME? " TIB 40 EXPECT
SPAN @ #TIB ! 0 >IN ! 1 TEXT CR ." HELLO, "
PAD COUNT TYPE ." , I SPEAK FORTH. " ;
All of the changes to this definition have been discussed previously, with the exception of the phrase
SPAN @ #TIB !
Since '83 Forth doesn't use a delimiter, but a count which determines the size of the input stream, in addition to reseting the input stream back to the beginning of the TIB with 0 >IN ! , you must also tell Forth how long the current stream is. #TIB controls the length of the input stream when you are not interpreting from disk. SPAN is a variable which is set by EXPECT , and which always contains the number of characters actually received by EXPECT . So by storing the value of SPAN in #TIB , we have told Forth that the input stream is as long as the name the user typed.
Number Input Conversions
Page 277
PLUS will not work as shown, since the version of NUMBER used in Blazin' Forth follows the recommendations of the '83 Standard, and always returns a double number. Use this version of plus on '83 systems:
: PLUS BL WORD NUMBER DROP + ." =" . ;
This just drops the high cell of the double number, which will be zero, if you are entering single length numbers. The word BL in the above definition is a system constant that returns the value for an ASCII blank (32). Generally, it's better to use constants like this when you have them, since they result in memory savings. I just threw it in as an excuse to tell you this.
Page 278
Footnote: See the system documentation for NUMBER PUNCT? and DPL ( which is equivalent to Brodies PTR ). See also the example in this document, under Chapter 7, which explains how to alter the behaviour of NUMBER .
Page 282
Blazin' Forths -TEXT returns TRUE if there is a match, unlike the one Brodie uses, which returns false if there is a match. You will need to keep this in mind if you want to get the file system example in the appendix to work.
*cn1;Chapter 11*cn0
Page 304
Because of the compiler security, the second definition for LIMIT won't work in Blazin' Forth. In many peoples view, this is kind of dubious practice, but if you want to use it, here's how to trick the security:
HERE 10 ALLOT
: LIMIT 2* LITERAL + [ HERE ] ; DROP
This keeps the stack position the same. Another way to do the same thing is:
: LIMIT 2* LIMIT + [ SP@ !CSP ] ;
Page 306
Handy Hint. Blazin' Forth will remain in compile mode until a ; is encountered, or a fatal error occurs. A message like <name> ALREADY EXISTS is not a fatal error. In fact, you can tell the system not to tell you about these errors at all, by typing:
WARNING OFF
To reactivate these non-fatal messages, type
WARNING ON
TEXT EDITOR VERSION 2.9
Creating a document
To start the text editor, just LOAD and RUN as you would any basic pogram.
Although this editor is written in machine language, it starts up with the
aid of a basic starting shell for ease of operation and copying.
Text memory will be cleared automatically, and your margins will be preset to
5 left, 75 right and 55 lines per page.
You can also manually clear the text buffer by selecting 1 (from the editor's
menu) and pressing RETURN. You will be asked to confirm the command (just a
safety precaution for those like myself who sometimes forget to save things
before erasing them).
If you wish to set up the margins and page length, use selection 2. Default
values are: left margin 5, right 75, lines per page, 55. The current value
will be displayed under the cursor, giving you a chance to either modify the
value or leave it intact (just pressing RETURN will use the current value).
Now enter the edit mode with selection 3 (default menu selection). If you
ever get a ?FORMAT ERROR message, it will probably be because the text buffer
needs to be initialized or the margins were set to illegal values (left > 77