Most programmers have heard of Forth. However, relatively few programmers have written software using Forth. Fewer still claim to have mastered Forth. The few who have readily admit that they are Forth fanatics.
My Forth-programming acquaintances have all the characteristics of being "true believers." To hear them speak of their devotion to Forth, you would get the impression they had undergone some sort of "peak experience." The evangelical fervor with which they talk about Forth is unlike anything I've heard from C, Pascal, or Assembler programmers. They're the kind of people who have their T-shirts emblazoned with the motto: "May the Forth Be With You!"
I tried learning Forth ten years ago when I was working with the HP 41C. I never did get to the point of thinking in Forth, so I do not claim to be an enlightened Forth programmer. I can, however, force myself into Forth when needed.
UTIL
Recently, Essex Marketing Services sent me a copy of UTIL for evaluation. UTIL is a Forth programming system for the HP 95LX and/or the Atari Portfolio computers.
The UTIL User's Guide explains how to install the three necessary files on either the HP 95LX or the Portfolio. The User's Guide is very clear on which parts of the manual pertain to one, the other, or both of these palmtop computers.
UTIL conforms to most of the '83 Forth standards for the language. It has almost all the features of Forth: a small interpreter/compiler, a small library, and a built-in assembler/ disassembler. The whole package runs in less than 30K bytes of RAM. UTIL, unlike other Forths, does not have its own text editor. On the 95LX, MEMO serves as the editor for writing Forth programs. In this way UTIL is "less filling," but the question remains: "does it taste great?"
A MATTER OF TASTE
Like olives, beer, or cottage cheese, Forth is an acquired taste. If you enjoy programming the HP 41C or the HP 48SX, you already have a taste of Forth. I'd recommend trying the real thing.
On the other hand, if you're a programmer who likes to work in C, Pascal, or BASIC, you may not get beyond the first few bytes before setting Forth aside and returning to the sweet taste of success with C or Pascal.
POST-FIX LOGIC
To begin with, Forth uses something called post-fix logic. To add two numbers in Forth, you key in 12 73 +. The + operator comes after the two numbers. That's just like using the RPN (Reverse Polish Notation) option in the 95LX's HP CALC program, right?
Then, to frustrate your fingers, Forth uses spaces all over the place. Thus, 12 73+ will never do what you expect: 12 73 + will! The space before the "+" sign is critical. The use of spaces is one of the rules of the Forth language, and it takes some getting used to.
Once you get beyond the hurdle of spaces and post-fix notation, you run into backwards code. For example, Forth uses "IF...ELSE...THEN" when everyone knows that the correct wording is "IF...THEN...ELSE" (or is it the other way around?)
UTIL'S UNIQUE FEATURES
UTIL on the HP 95LX goes a long way to help you acquire a taste for Forth. For one thing, UTIL comes with several sample programs.
MUSIC -- lets you turn the keyboard of the 95LX into a musical keyboard. Or, if you're conversant with musical notation, you can compose melodies in MEMO and play them with UTIL.
GRAPHICS -- a demo program of what can be done with the graphics screen of the 95LX. Most, if not all of the graphics commands are implemented as Forth words (i.e. functions). There are commands to fill rectangles, draw circles, and finger-paint. The source code for this program, and all sample programs, is included on the distribution disk.
GAMES -- Merlin and Mastermind are puzzles that have been on computers for almost a decade. Here they are again, this time written in Forth. Merlin is a tough puzzle to figure out. Mastermind works, but it lacks a good user interface. Apparently that is left as an exercise for the interested programmer. Both games can be run from within the UTIL program, or they can be compiled and run as stand-alone .COM files.
SYSTEM-MANAGER COMPLIANT
UTIL can pop up over most of the HP 95LX's built-in applications. Likewise, MEMO can pop up on top of UTIL. This feature will let you load, edit, and save a program file that you're working on, and then return to UTIL to test the program.
I have not been able to get UTIL to pop-up on top of Lotus 1-2-3. I suspect that there is not enough memory on my machine for both programs to exist simultaneously.
CREATING SYSTEM-MANAGER-COMPLIANT PROGRAMS
UTIL already has most of the code to let you create programs that are System-Manager-compliant. So even if you're not a registered Systems Developer, you can still write programs that do task-switching.
There are more than 25 Forth words (functions) implemented in UTIL that will let you talk to the System Manager and do such things as disabling light sleep mode for speed-critical applications. There are other words that manipulate the cursor and let you pull up menus and save and load a screen.
CREATING SYSTEM-MANAGER-EXECUTABLE PROGRAMS
Beyond using Forth words to write System-Manager-compliant programs, there is a simple way to make almost any .EXE or .COM file a "System-Executable" program. The procedure involves modifying the UTIL.EXM program rather than the .COM or .EXE file. A system-executable program will pop up over all built-in applications except Lotus 1-2-3. To re-enter a built-in application one must exit the system-executable program.
UTIL.EXM is 208 byte program that invokes, loads and runs the REAL Forth program, called SMU.COM. The Users' Guide shows how to modify UTIL.EXM so that it can load and run any small, .EXE or .COM file.
I followed the procedure in the Users' Guide and created a 208 byte file called HPTRIS.EXM which let me load and run the program called HPTRIS.EXE. I added the following line to my APNAME.LST file in my _DAT subdirectory:
c:\hptris.exm,2300,tetris
I then reset the 95LX and pressed <ALT>-h. Up popped my favorite battery waster: Tetris.
I performed a similar modification for a 39K byte, compressed version of VDE, my favorite text editor. Now VDE pops up on top of UTIL and makes a much better editor for writing Forth programs.
The procedure for making system-executable software is not too difficult to follow, but novices should not rush out and buy UTIL just to use this one feature. Instead, see discussion on menuing systems, page 19, developed from the UTIL Forth package.
PECULIARITIES OF UTIL
UTIL, like most small Forth compilers, does not support floating point arithmetic. Most Forth programmers seem to take this in stride. If something like floating point math is essential, you could probably use in-line assembler code to create a floating point math package. By the time this report appears in print, Essex Marketing expects to have a floating point package available for UTIL. In addition, the implementation of a screen-size edit buffer and clipboard support should be complete.
Another peculiarity of UTIL is that you need to be very specific when opening or saving files. The full path and file name is necessary when writing a file on the RAM disk of the 95LX. If you don't include the path, your file will probably wind up in the root directory. When trying to read a file, a missing path usually means you'll get an error message.
UTIL does not have any way to use the clipboard. Essex Marketing says that this feature is high on their list of enhancements for a future release of UTIL. I wish it was already implemented.
UTIL ON A CONVENTIONAL PC
One of the drawbacks for program development on the HP 95LX is the small keyboard. Even if you get used to typing memos and appointments, it's another matter altogether trying to type Forth code on the 95LX. I suppose anything is possible, but not all things are desirable. And one of the less desirable things in life would be entering Forth (or any language) source code on the 95LX.
I tried running UTIL.EXM on my desktop PC under the APP95 program (from the HP Connectivity Pack). I put the following in the APNAME.LST file on the desktop:
c:\cpack\util.exm,2f00,util
I then started up the APP95 program. Pressing the hot key got me nowhere. The UTIL program would not run.
However, I did find a way to get the SMU.COM program to work on the PC. Just use APP95's FILER to highlight the SMU.COM file and press F4. You'll see the UTIL screen in glorious light grey on blue.
This desktop environment will let you develop programs and test them out much more quickly than could be done on the 95LX alone. The people at Essex Marketing Services assured me that UTIL.EXM will work with the TKERNEL program from the Developer's Pack.
GETTING YOUR OWN COPY OF UTIL
UTIL retails for $70 and is available from Essex Marketing Services, Inc. 272 Old Farms Road Simsbury, CT 06070-1009, U.S.A.; Phone: (203) 651-8284; Fax: (203) 76-9481.
TO LEARN MORE ABOUT FORTH
If you are not familiar with Forth and would like to find out more about it, I'd recommend the following books.
You can't learn Forth just by reading about it. You have to play with it on a PC to see what will happen when you try to define your own words and compile them. To do this, I would recommend getting one or more public domain or shareware versions of Forth and trying them out on your desktop computer.
There is a Forth forum on CompuServe (GO Forth) which contains PYG .ARC * and UDFORT.ZIP *, a couple of small Forth compilers, as well as the biggest rendition of Forth to date. (See all 5 files of FPC35.ZIP. There's almost one megabyte of compressed code and documents in FPC [Forth-PC].)
In short, if you're familiar with Forth, or you want to try something new and different, I'd recommend UTIL Forth.
For those of you who have already purchased a license for UTIL, I'd like to hear your experiences and reactions to this fine product.
PASCAL 3.02 ON THE HP 95LX
In the premiere issue of The HP Palmtop Paper, I showed how to get Version 3.02 of Turbo Pascal to run on the HP 95LX (See Vol.1, No.0, Pg.31). Since then, I have had a number of requests for copies of the Turbo Pascal compiler and editor. The good news is that Borland, the creator of Turbo Pascal, has licensed at least one person to market and provide support for versions 3.01 and 3.02 of this out-of-print product. Those interested should contact: Joe Wright, 711 Chatsworth Pl., San Jose, CA 95128, U.S.A.; Phone: (408) 297-5594. Joe will provide you with a copy of Turbo Pascal 3.02 for $90.00 + 3.00 S/H.