Everything HP200LX: Knowledge, Products, Service

9 years, 100's of pages of HP Palmtop Paper, jammed with tips, reviews and how-to's

Most useful, up-to-date Web sites devoted to the HP 200LX

Direct link into 1000's of pieces of Palmtop software

Tips from Our Techs

2008 Catalog
(PDF, 2.6 MB)

Contact Us/About Us

Weekly Palmtop Paper Newsletter
(Palmtop tips, latest happenings, and HP Palmtop Paper Store information)



Privacy Policy

Programmer's Corner: LXBatch Programming

Programmers Corner: LXBatch Programming

LXBatch lets you create DOS batch files with the look and feel of the HP 200LXs built-in applications without the need for the HP Palmtop Developers Kit or a C compiler.

by Ed Keefe

A little background for LXBatch

 The unique feature of the HP palmtops is their ability to run older, but still useful, MS-DOS programs. Some HP palmtop owners have loaded their machines with Word Perfect and dBASE III+ as well as dozens of shareware and freeware programs. Yet, the most popular programs are those that have been custom designed for the HP 100/200LX (for example, acCIS, PalEdit, and HV). Such programs have the look-and-feel of the palmtops built-in applications. They all use the medium sized character fonts. They all have pulldown menus and they usually show the function key labels on the bottom of the screen.

 In the past, creating such look-alike applications required that programmers had to learn to use the HP palmtop Developers Kit. They also had to get a copy of Microsoft's C compiler, which could be costly and hard to come by.

 To overcome both these hurdles, the PAL (palmtop Application Library) group, under the leadership of Gilles Kohl, produced a library of C functions that work with almost any C compiler. Using the PAL library, programmers could design MS-DOS programs with the look-and-feel of native HP 200LX applications.

 However, for many people, the hurdles were still too high. Learning C and mastering all the HP 200LX function calls might be considered overkill, when all you needed was a DOS batch file. You might even have tried writing such a batch file, until you realized that batch files cant do everything that a full-blown program can do.

But wait: here's LXBatch!

 But suppose that your batch files could have pulldown menus, dialog boxes, file-and-directory pick-lists, dialog buttons, and input fields! Suppose they had the ability to check everything from battery type and battery voltage to the number of bytes free on a disk or in the DOS environment space! Suppose a batch file program could switch from one Software Carousel session to another! Suppose it could turn the HP palmtop Off and On. Suppose that your batch files had the ability to repeat an operation a number of times and then quit. Well, suppose no more: with a little help from LXBatch your batch files can now have all these features and more. This one program can breathe new life into dreary old batch files, all for the cost of a couple of days effort and the price of a postcard.

Rob Koenis, the author of the LXBatch program, has taken the best parts of the PAL library and turned them into a high-level programming language for the rest of us. With the LXBatch language, you wont have to wade through yards of C code and miles of error messages to get a program to work. Just run a couple of the sample programs that Rob provides, examine the on-line help files, and within a couple of hours you'll have a working batch file with almost any feature you want.

OK, in all honesty, creating LXBatch programs is not exactly a piece of cake. Some of the commands and the online help will leave you scratching your head and losing a few hairs in puzzlement. But when your program is up and running, you'll still have some hair left. Lots of C programmers cant make that claim!

 Some unique features of LXBatch

 LXBatch actually allows two kinds of program development: ordinary batch files that contain LXB commands and LXB programs that contain MS-DOS batch commands.

As an example of the former, here's a simple batch file, called SHOWKEY.BAT that uses some LXB


@echo off


echo This is a batch file with LXB commands


LXB screensetup

echo Note the Function Key Labels

LXB display 100 100 3 Note the function key labels

LXB showkeys Help View Edit Copy Save Exit

LXB getkey key

if %key% == F1 goto help

goto end


LXB message This is the help message


LXB screenrestore

 When you run the program, by highlighting the showkey.bat filename in FILER and pressing ENTER, you'll get the screen depicted in Screen 1.

 Screen 1: This screen was created by inserting LXB commands in an ordinary batch file.

 If you press the F1 key, you'll get the screen depicted in Screen 2 below.

 Screen 2: The LXB message command has put this text window on the screen.

 The showkey.bat file starts off as a typical batch file with the echo off command followed by commands to clear the screen, display a message and pause. The first enhanced command, LXB screensetup, puts the LX in graphics mode to handle subsequent LXB 7ommands. The command echo Note the Function Key Labels, another batch command, puts its message at the very top of the screen. The LXB version of the same command puts a similar message at location 100 pixels over and 100 pixels down on the screen using size 3, large, fonts. The LXB showkeys command fills in the function key labels at the bottom of the screen. (If a particular label is supposed to be empty, just use a pair of double quotes.) The LXB getkey command waits for a key and then stores the value of the key in the DOS environment variable key. The next command shows just the first in a possible series of if statements that compare the value of %key% to a predefined key. In this case, when you press the F1 key, the batch file will jump to the :help batch-file label and execute the LXB message command. This message command puts a text window on the screen and waits for any key to be pressed.

 The LXB screenrestore command puts the screen back in text mode.

This enhanced batch file may be just what you need to improve some of your current batch files. It will give you interactivity at the expense of a couple of extra commands.

If your LXB-enhanced batch file happens to use a lot of environment variables, you may run into a problem, especially if you try to run the batch file from FILER. You may run out of DOS environment space, and your program either wont run, or it will run and produce undesirable results. If this happens, its time to convert your batch file to a true LXB file and let LXBatch handle the environment variables for you. You'll get a faster running program as a reward for your effort. You'll think you have a double-speed palmtop in your hand.

 A Sample LXB program

 Here's an example of an LXB program. Its one of several sample programs contained in the LXBatch archive.

screensetup Pulldown menu demo

 message This is an LXB sample file|It will show how to make a Pulldown menu



 pulldownitem 0 &File &Edit &Help &Quit

 pulldownitem 1 &Open &Save Save &as .. - E&xit

 pulldownitem 2 &Cut C&opy &Paste

 pulldownitem 3 &Help - &About

 pulldownuse *pmenu

 if @pmenu@ == 4 goto end

 if @pmenu@ == 101 message Open file

 if @pmenu@ == 102 message Save file

 if @pmenu@ == 103 message Save file as ..

 if @pmenu@ == 105 goto end

 if @pmenu@ == 201 message Clipboard cut

 if @pmenu@ == 202 message Clipboard copy

 if @pmenu@ == 203 message Clipboard paste

 if @pmenu@ == 301 message No help

 if @pmenu@ == 303 message About|PullDown menu demo

 goto menustart




 When you run the program you'll see the opening message. (See Screen 3.)

 Screen 3: The opening message in the LXB example program.

 When you press any key, the pulldown menu will appear and will respond to the arrow keys. (See Screen 4.)

 Screen 4: The pulldown menu from the LXB example program.

 The thing to note about the SAMPULL.LXB file is the absence of the LXB key word. Since the LXBatch program will interpret the LXB file, it assumes that all commands are LXB commands except those that are obviously DOS commands. Also note that the pulldownuse *pmenu command replaces the LXB getkey key command. This command uses a value based on the pulldown item you've chosen. It stores the value inside LXBatch's data space rather than in the DOS environment space. To access the value of the variable you use @pmenu@ instead of the usual DOS variable name, %pmenu%.

To run the SAMPULL.LXB file, just use the command: LXB LXBFILE SAMPULL.LXB. (If you have a HP 200LX, you can use the undocumented FILER.INI file to associate an LXB file with the LXB LXBFILE command.) If typing this command is too much work, then you can compile the LXB file and turn it into a standalone EXE file. You'll be able to execute the EXE version of your program from FILER or by typing the name of the file at the DOS prompt. You could also distribute this file to others without having to show them how to use LXB!

But wait: there's more...and more...and more.

 LXBatch will let you enhance your current batch files, or create interpreted or compiled LXB files. You'll be able to enhance your batch programs with more than 100 new commands.

To try and list all these new commands would be tantamount to rewriting the documentation and help files provided by Rob Koenis; something that I don't want to do. (Besides, I cant write with a Dutch accent, as Rob can.) However, if you have not yet explored the range of things that LXBatch files can do, here are a few of the commands, just to whet your appetite.

ShowPCX: You may be able to eliminate other PCX graphics viewers by using this built-in command. There's also the ShowIcon command that will let you display the icons used on the HP palmtops.

Sound: This command will let you play everything from a simple beep to any to the tinkertunes that can be played on the LX's tiny speaker. A companion volume command will set the sound level.

Dialog commands: These commands create buttons, text and input fields: all the things that go to make up a dialog box. There's even a command called FileDialog that puts a file browser on the screen. You can use this command in a batch file to pick one file from a list.

Check commands: Your batch files can check on the status of almost everything that can happen in your palmtop, e.g., CheckKey, CheckBatt, CheckSC (Software Carousel), CheckEOF (End Of File: used with the ReadFile command), CheckDrive, CheckFree, CheckWeekDay, CheckEnvFree, CheckString.

String commands: LXBatch contains a panoply of string functions that will let you parse strings that are typed into an input window, as well as strings that are read in from other files.

Conditional and goto functions: LXBatch goes beyond the usual batch file commands such as if errorlevel, or if /%1 == / , to offer such commands as if (not) x<y, and if (not) x>y. There's even a calc command that can be used to perform counted loops. For example, here is a simple FORLOOP.LXB program that puts the numbers 1,2,3,4,5 diagonally across the screen. Its not the ultimate program, but it shows some of the additional capabilities of LXBatch. In the program, the *variablename indicates an LXBatch variable that will hold a value: the @variablename@ indicates the value stored in the variable.


 ; initialize 3 variables

 set *counter 0

 set *x 0

 set *y 0


 ; add 1 to counter

 calc *counter @counter@ + 1

 calc *x @x@ + 100

 calc *y @Y@ +20

 display @x@ @y@ 3 @counter@

 if not @counter@ == 5 goto loop

 getkey *key

 ; delete the variables

 set *counter

set *x

set y


 When you run the FORLOOP. LXB file with the command LXB LXBFILE FORLOOP. LXB, you'll see what's depicted in Screen 5.

 Screen 5. In this example, the calc command is displaying numbers diagonally across the screen.

Menu commands: Besides the Pulldown menu commands shown above, LXBatch has a set of commands that will let you create pop-up menus anywhere on the screen. You can then use the UpArrow and DownArrow keys to pick a command from a scrollable list. What more could a busy programmer ask for?

 LXBatch as a prototyping tool

 For many programmers, LXBatch may be all that you'll ever need. However, if you're designing an application for yourself or a customer, you'll find that LXBatch can serve as a great prototyping tool. You can have a mock up of a palmtop program in a day or two. If this meets with the approval of the customer, you can either compile it and sell it, or you can use it as the starting point for developing a C program that does the same thing, along with whatever else the customer wants.

The LXBatch program is my top pick for the palmtop Programming Tool of the year. It lets me write programs on the palmtop without the usual fuss and bother of a C or Pascal compiler. To expedite LXBatch programming, I keep a copy of LXB.DOC, the documentation file for LXBatch, in one of three Software Carousel sessions on my palmtop. I devote a second SC session to the PalEdit editor, which I use to develop the code for a LXB file. My third SC session is where I test the program as I develop it. I also have an emergency repair program which gets me back in business after the occasional crash and reboot.

Coming next month: CHOICE.LXB

 Compared to developing similar programs on a desktop, the operation is lean, mean and fast. To get a better idea of the type of program that Imp working on, look for next months issue of The HP Palmtop Paper. It will contain an extensive, and thoroughly documented LXB file called CHOICE.LXB. The program uses the FILER.INI file and lets me point at almost any file in FILER and have a choice of Running, Editing, Viewing, or Unzipping the file. The program is one of those hacks that will probably never be finished because it just keeps growing and growing. Hopefully, Ill have it ready for your inspection by the next issue. Until next time, Happy Programming: this time with LXBatch.

Shareware/Freeware mentioned in this article

iPhone Life magazine

Notice about Palmtop.net
The Palmtop Network with its S.U.P.E.R. (Simply Unbeatable Palmtop Essentials Repository) software is now available under the domain name of hp200lx.net.  

We Buy
We buy used palmtops, working or broken: HP 200LX, HP 100LX and 1000CX.

Copyright 2010 Thaddeus Computing Inc