text
stringlengths 0
99.6k
|
|---|
<> Leaves a true flag if top of stack is not equal to second element of stack.
|
D> Leaves a true flag if the second double number is greater than the doublenumber on the top of the stack.
|
CONDITIONAL EXECUTION
|
BEGIN...AGAIN is included. It is the same as
|
BEGIN .... FALSE UNTIL
|
Or, in other words, an infinite loop.
|
Multiple WHILEs are supported by Blazin' Forth. For example:
|
BEGIN <action> <condition> WHILE <action> <condition> WHILE <action> REPEAT
|
Note that you are not limited to only two whiles, this is simply an example.
|
LOOPING
|
Forth-83 loops are very fast, make the older /LOOP unnecessary, and are generally much improved over the earlier Forth Loops. However, when the loop index is equal to the loop limit, the loop will not execute once, but 64k times. For occasions when this is not wanted, Blazin' Forth provides ?DO . ?DO will not allow the loop to be executed if the limit and index are equal. For example:
|
: LOOP1 ?DO I . LOOP ;
|
Does the same thing as:
|
: LOOP2 2DUP <> IF DO I . LOOP ELSE 2DROP THEN ;
|
Note that the first is much shorter, and also much faster. Of course, ?DO will also work with +LOOP, just like DO does.
|
Forth-83's LEAVE is also changed from earlier LEAVEs. Forth-83's LEAVE jumps immediately to the word after LOOP or +LOOP, while the older LEAVE would continue through the remainder of the loop, exiting at the LOOP or +LOOP. Blazin' Forth contains a word, ?LEAVE which can be quicker and a real code saver when all you need to do is scram. For example:
|
: EXIT1 10 0 DO I . 5 = ?LEAVE LOOP ;
|
Will cause the same effect as:
|
: EXIT2 10 0 DO I . 5 = IF LEAVE THEN LOOP ;
|
Note that ?LEAVE takes less room, and is also quicker, than the second alternative.
|
Interactive Extensions
|
?KEY ( -- char )
|
This word works just like the standard KEY , but while KEY will wait for a keypress, ?KEY reads the keyboard, and returns the ASCII value of the key pressed, or a null (0) if no key was pressed.
|
PAUSE ( -- flag)
|
This word is basically a souped up ?TERMINAL. ?TERMINAL will return a TRUE flag if the stop key is pressed, and false otherwise. PAUSE will do the same thing, but, additionally, if any key other than the stop key has been pressed, it will halt execution and wait for the next key. Note that although PAUSE handles the waiting, it is up to the calling word to process the flag.
|
JOYSTICK ( port# -- direction )
|
Requires a value on the stack, which should be either 0 or 1. If 0, joystick port 1 will be read, If 1, joystick port 2 will be read. Joystick leaves a value on the top of the stack which indicates the direction of the joystick. -1 means the stick is centered, 0 is up, with values increasing to the right, so 1 is forward and up, 2 is to the right, etc. Note that if these values are multiplied by 45 the result is suitable for SETH (see graphics extensions).
|
JOYBUTTON ( port# -- flag )
|
Leaves true on the stack if the joy stick button at the appropriate port is depressed, otherwise leaves false. Requires the same values on the stack as JOYSTICK.
|
PADDLE ( paddle# -- value )
|
Requires a number from 0 to 3 on the stack which specifies the paddle. Leaves a value between 0 and 255 on the stack, depending on the setting of the appropriate paddle. Note that these words may also be used to read other devices, such as a Koala Pad.
|
PADDLEBUTTON ( paddle# -- flag)
|
Leaves a true or a false on the stack, depending on whether or not the addressed button has been depressed. Requires the same values as PADDLE.
|
JIFFY! ( doublenumber -- )
|
Used to set the 64's Jiffy Clock. Requires a double number on the stack.
|
JIFFY@ ( -- doublenumber )
|
Used to read the 64's Jiffy Clock. Leaves a double number on the stack. Note that 1 Jiffy = 1/60 of a second.
|
JIFFIES ( n -- )
|
Requires a single number on the stack. JIFFIES will cause a wait of n jiffies before continuing.
|
CURSOR ( x y -- )
|
Positions the cursor at the x y coordinates on the top of the stack.
|
CURSORPOS ( -- x y )
|
Leaves the current position of the cursor ( x and y ) on the top of the stack.
|
CONSTANTS
|
Blazin' Forth has precompiled the following constants.
|
0 1 2 3
|
These simply leave their value on the stack.
|
TRUE
|
Leaves the value for TRUE (-1) on the stack.
|
FALSE
|
Leaves the value for FALSE (0) on the stack.
|
VARIABLES
|
Blazin' Forth has the following variables which may be of use to you:
|
#LINE
|
A user variable which contains the number of times the word CR has been executed. May be examined to control output formatting. Note that this word is reset by PAGE to 0.
|
#OUT
|
A user variable which contains the number of characters TYPEd or EMITted since the last CR. Note that words such as SPACE or SPACES, which use EMIT, will also bump this variable. May be examined by the user to control output formatting. CR resets to 0.
|
DPL
|
A user variable which contains the number of places after the decimal point for input conversion.
|
FENCE
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.