GforthBlockEditing

Gforth verbs for working with block storage.

VERBSTACK-EFFECTDESCRIPTION
open-blocksc-addr uUse the file, whose name is given by c-addr u, as the blocks file.
use "file"Use file as the blocks file.
block-offsetaddrUser variable containing the number of the first block (default since 0.5.0: 0). Block files created with Gforth versions before 0.5.0 have the offset 1. If you use these files you can: 1 offset !; or add 1 to every block number used; or prepend 1024 characters to the file.
get-block-fid wfileidReturn the file-id of the current blocks file. If no blocks file has been opened, use blocks.fb as the default blocks file.
block-position uPosition the block file to the start of block u.
list uDisplay block u. In Gforth, the block is displayed as 16 numbered lines, each of 64 characters.
scr a-addrUser variable – a-addr is the address of a cell containing the block number of the block most recently processed by list.
blockuIf a block buffer is assigned for block u, return its start address, a-addr. Otherwise, assign a block buffer for block u (if the assigned block buffer has been updated, transfer the contents to mass storage), read the block into the block buffer and return its start address, a-addr.

buffer u – a-addr block “buffer”

If a block buffer is assigned for block u, return its start address, a-addr. Otherwise, assign a block buffer for block u (if the assigned block buffer has been updated, transfer the contents to mass storage) and return its start address, a-addr. The subtle difference between buffer and block mean that you should only use buffer if you don't care about the previous contents of block u. In Gforth, this simply calls block.

empty-buffers – block-ext “empty-buffers”

Mark all block buffers as unassigned; if any had been marked as assigned-dirty (by update), the changes to those blocks will be lost.

empty-buffer buffer – gforth “empty-buffer”

update – block “update”

Mark the state of the current block buffer as assigned-dirty.

updated? n – f gforth “updated?”

Return true if updated has been used to mark block n as assigned-dirty.

save-buffers – block “save-buffers”

Transfer the contents of each updated block buffer to mass storage, then mark all block buffers as assigned-clean.

save-buffer buffer – gforth “save-buffer”

flush – block “flush”

Perform the functions of save-buffers then empty-buffers.

load i*x n – j*x block “load”

Save the current input source specification. Store n in BLK, set >IN to 0 and interpret. When the parse area is exhausted, restore the input source specification.

thru i*x n1 n2 – j*x block-ext “thru”

load the blocks n1 through n2 in sequence.

+load i*x n – j*x gforth “+load”

Used within a block to load the block specified as the current block + n.

+thru i*x n1 n2 – j*x gforth “+thru”

Used within a block to load the range of blocks specified as the current block + n1 thru the current block + n2.

--> – gforth “chain”

If this symbol is encountered whilst loading block n, discard the remainder of the block and load block n+1. Used for chaining multiple blocks together as a single loadable unit. Not recommended, because it destroys the independence of loading. Use thru (which is standard) or +thru instead.

block-included a-addr u – gforth “block-included”

Use within a block that is to be processed by load. Save the current blocks file specification, open the blocks file specified by a-addr u and load block 1 from that file (which may in turn chain or load other blocks). Finally, close the blocks file and restore the original blocks file.