The ANS standard file words are all implemented, including the extension wordset. The values of IOR that you might obtain are calculated as: -256-OZerror. Therefore, an OZ error code of RC_ONF (18) will be given as an IOR value of -274.
You can load source from any text file using the standard INCLUDED and INCLUDE-FILE words. For example:
S" proggy.fth" INCLUDED
Sources can be nested up to 8 levels, although PAD will be overwritten once more than 5 or 6 levels are reached. Quite why anyone would want to do this is beyond me, but that's ANS for you...
Both CR and LF are acceptable as line-terminators, so CRLF is also acceptable (if using READ-LINE you would notice an extra blank "line" after every line).
You can use devices (such as :COM.0 etc) for files, but this may give strange effects when nesting input to include other files, since the interpreter reads a line at a time, and will attempt to "rewind" the input to the start of the line containing the INCLUDED (or whatever) word - this works fine with files, but is not a very good idea with input from other devices...
Before using any block words, you need to specify the number of block buffers you would like (1-4) allocated in RAM. This is done as follows:
which allocates 2 block buffers, for example. Next you need to "map" one or more files to a range of blocks. Four ranges are available, so you can have up to 4 files mapped at the same time. The ranges are as follows:
You can map a file to a range of blocks in the following way:
S" myblocks.blk" 0 MAP
to map a file to range 0, for example. Before exiting or doing a COLD, you must remember to unmap each range, otherwise the file will be left in an open state and a soft reset will be necessary. For example:
Using either MAP or UNMAP always causes buffers to be FLUSHed (even those containing blocks mapped to other ranges), so remember that all buffers will be invalid at this point.
It's worth noting that there is no correlation between the number of block buffers and the number of mapped files; the system will work just as well with 4 buffers and 1 mapping, as with 1 buffer and 3 mappings, or any other combination.
A loadable block line editor is also supplied, plus some file/block conversion utilities.
Also included is a block file called tools.blk which contains everything which is provided in the separate loadable files. Map this file to range 0, and use 1 LIST (with the line editor loaded) to see which blocks contain which utilities.
More about CamelForth
Back to the Z88 home page