Learn 4tH the easy way
We have introduced a new series, in which we will teach you how to program in 4tH. Contrary to most other Forth textbooks (sorry Leo, I didn't mean you!),
we won't get as quickly into the internals as possible. Instead, we will try to get you working with 4tH, writing the program you'd want to create. Not to program a handheld device, a robot or an array of LEDs.
You can study the lessons in peace and try out the examples. You don't use 4tH? Why not? It runs on most platforms and is absolutely free!
But if you insist you can make your ANS-Forth compiler 4tH-compatible and use this tutorial anyway! So have fun and learn Forth the 4tH way. Maybe you never want to leave. Or you even might be tempted to switch to 4tH!
If you do have any questions, please contact us. We have acquired quite a reputation here, answering most emails within 24 hours.
Level 0
- Making calculations
- Manipulating the stack
- Deep stack manipulators
- Passing arguments
- Making your own words
- Adding comment
- Text format of 4tH source
- Displaying constant strings
- Declaring variables
- Using variables
- Built-in variables
- What is a cell
- What is a literal expression
- Declaring arrays of numbers
- Using arrays of numbers
- Declaring and using constants
- Built-in constants
- Using booleans
- IF-ELSE constructs
- FOR-NEXT constructs
- DO-WHILE constructs
- REPEAT-UNTIL constructs
- Infinite loops
- Getting a number from the keyboard
Level 1
- Aligning numbers
- Creating array of constant numbers
- Using arrays of constant numbers
- Creating strings
- Initializing strings
- Getting the length of a string
- Printing a string variable
- Copying a string variable
- Slicing strings
- Appending strings
- Comparing strings
- Removing trailing spaces
- String constants and string variables
- The string terminator
- Printing individual characters
- Getting ASCII values
- Printing spaces
- Fetching individual characters
- Storing individual characters
- Terminating strings
- Getting a string from the keyboard
Level 2
- The Character Segment
- What is the TIB?
- What is the PAD?
- How do I use TIB and PAD?
- Simple parsing
- Converting a string to a number
- Controlling the radix
- Pictured numeric output
- Converting a number to a string
- Opening a file
- Reading and writing from/to a file
- Closing a file
- Writing text files
- Reading text files
- Reading binary files
- Writing binary files
- Parsing a textfile
- Parsing a binary file
- The layout of the Character Segment
Level 3
- The Code Segment
- The address of a colon-definition
- Vectored execution
- The Integer Segment
- Using values
- A portable way to access application variables
- Returning a result to the host program
- Using commandline arguments
- The layout of the Variable Area
- The stacks
- Saving temporary values
- The Return Stack and the DO..LOOP
- Other Return Stack manipulations
- Altering the flow with the Return Stack
- Leaving a colon-definition
- The layout of the Stack Area
- Booleans and numbers
- Using ' with other names
- Assertions
- Random numbers
- Time and date
- What is not implemented
- Known bugs and limitations
Level 4
- Conditional compilation
- Exceptions
- Lookup tables
- Interpreters
- Records and structures
- Multidimensional arrays
- Using a printer
- Fixed point calculation
- Recursion
- Forward declarations
- This is the end