Table of Contents

Gforth — GNU Forth for Android

Project goal is to use Gforth as programming system on Android.

Project Status

Starting the app first time unpacks the Gforth sources to the SD card. That's a few megabytes, and therefore it takes its time. Gforth shows a spinning wheel while it's doing so, but can't respond to any input events. If the spinner shows you “Done; restart Gforth” for a while, you should kill and restart Gforth - it got stuck. If you still have problems, there's a gfortherr.log and a gforthout.log in /sdcard, which might provide more diagnosis.

The terminal uses a fragment shader, which implements a colored ASCII terminal - it uses two textures, one with the character set, and another with the characters and colors. An update of the terminal screen therefore only takes a few milliseconds - just like it used to be with in text mode. This has been tested with several really cheap phones with awful OpenGL implementations, so it should work on yours, too.

I recommend the following keyboards (in that order):

Since Android apps can't be started from the command line, you can enter options for starting Gforth in the file /sdcard/gforth/home/.options. One line per option. -d64k e.g. sets the stack to 64kB, -m16M the dictionary to 16MB, see http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Invoking-Gforth.html

Examples

All Android examples are packet into /sdcard/gforth/<version>/minos2. There is

JNI Interface

Android's native API is Java. To access Java, the vocabulary jni contains helper words and some predefined interface words. Calls to Java are usually related to some object; the interface is compatible to Mini-OOF2 with its current objects.

To define a method or a field, you use the following words:

OpenGL

The vocabulary OpenGL contains OpenGL ES 2.0 bindings (generated from the header files, including extensions and EGL bindings).

Troubleshooting

Gforth logs info into the files /sdcard/gfortherr.log and /sdcard/gforthout.log. If something goes wrong, look here if you find an error message. If a source file is missing or defect, you can remove /sdcard/gforth/; it is sufficient if you delete the file sha256sum in the subfolder with the current release name. Sometimes, files move after an update, in that case, you might better remove the entire /sdcard/gforth/.

Documentation

Gforth has a big manual, which is also available as eBook PDF (some non-breakable texts are cut off in this small size).