WebForth will read in a PARAM tag in the form:
<PARAM name=boot value="INCLUDE En/1stPrgS.htm">
When the WebForth applet initializes, it will automatically interpret and
execute the boot string.
WebForth has single-stepping and animated TRACE debugging.
To single-step the Forth virtual machine instructions, enter STEP
followed by the name of the word you want to watch. The top elements
of the data stack and the return stack are shown, along with the
instruction pointer (ip) and the name of the next high-level or
primitive word to be executed. If the data stack depth is more than
one, the depth of both stacks is shown on a second line. To continue
with the next instruction, hit a key. If you hit the Escape key,
the word will run to completion without any more display or stepping.
The TRACE word works the same way, but does not break between words.
The escape key still works with TRACE.
WebForth has memory access checking through the Java
exception-handling mechanism. If you try to access an invalid address,
such as 2000000 @, you will see the error prompt "address ?" and your
stacks will be cleared. This has not added much of a performance
penalty, but will help students of Forth catch memory bugs more
quickly.
WebForth has a USER variable named CAPS that you may fetch or change. By default, it is cleared to 0, so WebForth is not case-sensitive. This should help users who don't like typing UPPER CASE words! Please note that the current version of WebForth, when CAPS is 0, still refuses to convert hexadecimal numbers containing lower-case digits (a to f), so use A to F. To implement optionally case-insensitive string matching, I have implemented the following words:
ISLOWER? ( c -- f)
returns TRUE if character is a lower case letter ('a' to 'z')
UCASE ( c -- c')
replaces the character on stack with upper case version
if and only if it is a lower case letter ('a' to 'z')
UCASE? ( c -- c')
replaces the character c with upper case version
if and only if it is a lower case letter ('a' to 'z')
and if the CAPS variable holds a zero
For fun, I also added the following filtering words:
@UCASE! ( a -- )
replaces the character at addr. a with upper case version
if and only if it is a lower case letter ('a' to 'z')
TOUPPER ( c$ -- )
replaces all lowercase letters in the counted string with
upper case equivalents
Then I modified SAME? to use UCASE? after fetching each character of the two strings to be compared. This allows one to place names in the name dictionary with the letters in the exact case as they are typed, but when typing and compiling, letters of any case will match if the CAPS variable is cleared to 0.
To give other web designers and experimenters more flexibility, there are some
applet parameters to make the number of rows and columns of text
flexible. The default is still 72 by 20, but you can set it to something else if
you want. Correspondingly, you can also set the fontsize to anything you want.
For most applications, sizes of 10, 12, and 14 will make the most sense. Perhaps
later I will add parameters for font shape and style as well. The format for these
settings inside the <applet ...> ... </applet> pair is:
<PARAM name=cols value="72">
In WebForth you can change the text colors during your output by changing
the contents of two user variables FGCOLOR and BGCOLOR, where the value must be an
integer with bits 16-23 representing red, bits 8-15 representing green, and bits
0-7 representing blue. (In hexadecimal: 00RRGGBB). There are some standard names
for standard colors: BLACK, WHITE, RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA, GRAY,
DARKGRAY, LIGHTGRAY, DARKRED, DARKGREEN, and DARKBLUE. Standard EMIT and TYPE
should output the current colors.
<PARAM name=rows value="20">
<PARAM name=fontsize value="12">
In WebForth, PAGE clears the screen (to the current BGCOLOR), and AT-XY will move the cursor to the row and column numbers specified on the stack. MS will pause the execution for the specified number of milliseconds.