#BLOCKS ( -- UNSIGNED )
UNSIGNED is the number of blocks available in the block file.
(BLOCK) ( CDATA -> CHARACTER UNSIGNED FLAG -- SIGNED )
If FLAG is FALSE, read the contents of block UNSIGNED from the block file into the buffer with start address CDATA -> CHARACTER. If FLAG is TRUE, write the contents of the buffer starting at CDATA -> CHARACTER to block UNSIGNED of the block file. SIGNED is zero if and oly if the operation was successfully executed.
An ambiguous condition exists if UNSIGNED is not a valid block number.
(CATCH) ( TOKEN INTEGER -- SIGNED )
Extend the execution semantics of (CATCH) with the following:
Consider BLK as part of the input source specification.
?BLOCK ( UNSIGNED -- )
Checks whether UNSIGNED is a valid block number. An exception is thrown if UNSIGNED is zero or greater than the number of the last block.
BLK ( -- DATA -> UNSIGNED )
DATA -> UNSIGNED is the address of a cell containing zero or the number of the block being interpreted. If BLK contains zero, the input source is not a block, and can be identified by SOURCE-ID. An ambiguous condition exists if a program directly alters the contents of BLK.
BLK-BUFF ( -- CDATA -> CHARACTER )
CDATA -> CHARACTER is the address of a single buffer for C/B characters, called block buffer. This buffer is always used when transferring a block from or to the block file.
BLK-STAT ( -- DATA -> SIGNED )
DATA -> SIGNED is the address of a cell containing a number that describes the status of the block buffer. If the number is zero, the block buffer is unassigned. Otherwise, the block buffer is assigned to the block whose number is the absolute value of the number. If the number is negative, the block buffer has been modified with respect to the block in the block file it is assigned to.
BLOCK ( UNSIGNED -- CDATA -> CHARACTER )
If the block buffer is unassigned, transfer block UNSIGNED from the block file to the block buffer.
If block UNSIGNED is not already in the block buffer, and the block buffer is assigned but has not been modified, transfer block UNSIGNED from the block file to the block buffer.
If block UNSIGNED is not already in the block buffer, and the block buffer is assigned and has been modified, transfer the block to the block file and then transfer block UNSIGNED from the block file to the block buffer.
Assign block UNSIGNED to the block buffer. CDATA -> CHARACTER is the address of the block buffer.
Exceptions are thrown if UNSIGNED is not a valid block number or if a block buffer can not be written to or read from the block file.
BUFFER ( UNSIGNED -- CDATA -> CHARACTER )
If block UNSIGNED is not already in the block buffer, and the block buffer is assigned and has been modified, transfer the block to the block file.
Assign block UNSIGNED to the block buffer. CDATA -> CHARACTER is the address of the block buffer.
Exceptions are thrown if UNSIGNED is not a valid block number or if a block buffer can not be written to or read from the block file.
C/B ( -- UNSIGNED )
UNSIGNED is the number of characters in a block (1024).
C/L ( -- UNSIGNED )
UNSIGNED is the number of characters in each line of text in a block (64).
EMPTY-BUFFERS ( -- )
Unassign the block buffer. Do not transfer the contents of the block buffer to the block file.
ERROR ( SIGNED -- )
If SIGNED is neither -1 nor -2, extend the execution semantics of ERROR with the following:
If the input source is a block, display the block number and the line number within the block. If SIGNED is between -3 and -303, display a user readable error message instead of an error number.
EVALUATE ( CDATA -> CHARACTER UNSIGNED -- )
Save the content of BLK, store 0 in BLK, and perform EVALUATE. Then restore the content of BLK.
FLUSH ( -- )
Perform the function of SAVE-BUFFERS, then unassign the block buffer.
LIST ( UNSIGNED -- )
Display block UNSIGNED as 16 lines of text. Store UNSIGNED in SCR.
LOAD ( UNSIGNED -- )
Save the current input source specification. Store UNSIGNED in BLK, thus making block UNSIGNED the input source and setting the input buffer to encompass its contents. Set >IN to zero and interpret. When the parse area is exhausted, restore the prior input source specification. Other stack effects are due to the words LOADed.
An exception is thrown if UNSIGNED is not a valid block number.
QUIT ( -- )
Store 0 in BLK and perform QUIT.
REFILL ( -- FLAG )
Extend the execution semantics of REFILL with the following:
When the input source is a block, make the next block the input source and current input buffer by adding one to the value of BLK and setting >IN to zero. Return TRUE if the new value of BLK is a valid block number, otherwise FALSE.
REFILL is a deferred definition.
RESTORE-INPUT ( INPUT-SOURCE -- FLAG )
Attempt to restore the input source specification to the state described by the tuple INPUT-SOURCE. The input source specification may be the user input device, a character string, or a block. FLAG is true if the input source specification cannot be restored.
An ambiguous condition exists if the input source represented by the arguments is not the same as the current input source.
SAVE-BUFFERS ( -- )
If the block buffer is marked as modified, transfer its contents to the block file. Mark the block buffer as not modified. An exception is thrown if the block buffer is assigned to an invalid block.
SAVE-INPUT ( -- INPUT-SOURCE )
INPUT-SOURCE is a tuple that describes the current state of the input source specification for later use by RESTORE-INPUT. The input source specification may be the user input device, a character string, or a block.
SCR ( -- DATA -> UNSIGNED )
DATA -> UNSIGNED is the address of a cell containing the block number of the block most recently LISTed.
SOURCE ( CDATA -> CHARACTER UNSIGNED -- )
Extend the execution semantics of SOURCE with the following:
When the input source is a block, CDATA -> CHARACTER is the address of the block buffer assigned to block BLK, and UNSIGNED is the number of characters in the block.
SOURCE is a deferred definition.
THROW ( SIGNED -- )
Extend the execution semantics of THROW with the following:
Consider BLK as part of the input source specification.
THRU ( UNSIGNED 1ST -- )
LOAD the blocks numbered UNSIGNED through 1ST in sequence. Other stack effects are due to the words LOADed.
An exception is thrown if UNSIGNED is greater than 1ST, or if either UNSIGNED or 1ST are no valid block numbers.
UPDATE ( -- )
Mark the block buffer as modified.
Note: UPDATE does not immediately cause a transfer to the block file.
\ ( "ccc\" -- )
Compilation:
Perform the execution semantics given below.
Execution:
If BLK contains zero, parse and discard ccc delimited by
a second \ (backslash), but at most until the end the parse
area. Otherwise parse and discard ccc delimited by a second \
(backslash), but at most the portion of the parse area corresponding to
the remainder of the current line.
\ is an immediate word.
Dr. Stephan Becher - January 9th, 2008