Edit this page

herkforth Compile Time Tutorial

First you will need to build herkforth.

Then run herkforth.

You will now see the herkforth editor.

We'll want our own "block" to program in, so if you see a bunch of source code (red, green, and/or yellow words) type new-block and press enter.

Now you should have an empty (except for a yellow zero) block to program in.

First lets do some simple math stuff to get started. Type the following words with spaces after each (be careful to type a space after the last one, not enter.)

3 4 + .

They should pop into the source after the yellow zero when you press space. So your source should look like this:

[ 0 3 4 + .

Now let's save your progress. press SHIFT-S. (Nothing appears to happen except sometimes a flicker, but when you quit you should see a program called herkforth002 which when run will bring you back to what you see on the screen now.)

--- Making Corrections ---

If you are typing a word, you can delete letters one at a time with delete/backspack as normal.

If you would like to delete words that you see in the source, use backslash \. Backslash will delete the word under the cursor.

If you accidentally delete anything you'd like to keep, you can paste it right back in with SHIFT-U.

----

OK, let's delete that yellow zero. Press SHIFT-H until the cursor is over the yellow zero, and press backslash.

OK, now the source code looks good:

[ 3 4 + .

For those of you who don't know forth, here's the translation, word for word:

Now lets save again. Press SHIFT-S. (It's always a good idea to save before executing new code, just in case that code crashes the system badly.)

Now lets run the code! Press SHIFT-B. This runs the code in the current block. You should see a 7 printed down by your cursor.

That's it for this tutorial. You can continue to the herkforth Run Time Tutorial for how you can make little lines of code like this (except maybe more useful) easily accessible by name.

See Also

herkforth tutorials

herkforth docs

herkforth

Edit this page · home ·