|Everything HP200LX: Knowledge, Products, Service|
COLUMN: PROGRAMMER'S CORNER
Are you a programmer or registered developer for the HP 95LX? If so, then this column is for you.
Hopefully, this column will become your special section of The HP Palmtop Paper. It will be a chance for you to pick up some new ideas, pose a problem or solve a problem from other programmers.
Let me start by mentioning that I am a teacher of computer programming. I view this column as an extension of my teaching activity. For me, teaching is just another word for learning. As a teacher, I have the privilege of learning from some of the brightest students around.
My style of teaching is more a sharing of ideas and problems rather than a didactic presentation of facts.
If I discover a new idea, or run up against a knotty problem, I tend to share it with others. My expectation is that I will learn more from an exchange of ideas than by keeping my knowledge, or ignorance, to myself.
So, what you may expect to find here is a free exchange of ideas, problems, questions, and tentative answers. Over the life of this column you may expect to see more of your own responses and less of my ruminations.
I earnestly invite your responses. Remember, you are the teachers. I'm the learner in this column.
Let's begin by taking a look at some of the problems that are peculiar to the HP 95LX.
Once Upon a Small Screen
The small screen of the HP 95LX may pose a problem for some programmers. The problem arises not so much from putting text on the screen, but rather from getting the "right" text on the screen. Just when we were getting used to writing elaborate Help screens, full of pull-down menus and pop-up windows, we are confronted with a screen that calls for brevity, clarity, and conciseness.
Here's a suggestion that may help you reduce the number of words in a help screen without losing any of its meaning. Try pushing your text through a grammar checker such as QUE's RightWriter program. I've tried this with several help screens and found that I could say the same thing in one screen that originally took two.
If you like to use line graphics to make a screen more eye-appealing, you will run into another problem with the HP 95LX.
The HP 95 uses the Lotus International Character Set (LICS) rather than the IBM character set. As a result, you can't use many of the line graphics characters. In particular, the line characters that mix double and single line characters are missing from LICS.
For now, the best work-around is to stick with either all double-line or all single-line characters.
Now, here is a question for those who have dug deeper into their HP 95 than I have. I recall that the HP 110 and HP Portable Plus had the ability to switch between the HP character set and the IBM character set. I wonder if the full IBM character set is buried somewhere in the memory of the 95LX and, if so, is there a way to use it? If not, is there a way to load the IBM character set from a font file and use that in place of the LICS characters? Has anyone tackled this problem? Let us know.
The graphics screen of the HP 95LX is somewhat unique as well. It is not like the screens found in most color computers. Rather it is a simple, bit mapped display. I suspect that it behaves somewhat like a monochrome display screen with a Hercules card. However, in the case of the 95LX, there is no plug-in card. You'll have to write your own screen driver to take advantage of any graphics presentations.
Here's an idea. Borland's Turbo C and Turbo Pascal both use BGI (Borland Graphic Interface) drivers for all of the current graphics screens. Borland also provides a BGIKIT file for those who want to write their own screen drivers. Is anyone willing to experiment with this to see if it is more than a blind alley? The BGIKIT is available on CompuServe in the Borland forum (go bproga).
Another intriguing approach to graphics on the 95LX is the use of PCX graphics files. The opening screen of the 95LX uses a PCX file. If you've found your way into the \_SYS directory, you've spotted 1000.PCX and have probably used that as a novel replacement for the usual opening screen. If you haven't tried this yet, just use the Set-Up key and choose Owner, then Picture. Enter the picture file name as C:\_SYS\1000.PCX and then quit back to the opening screen.
So the double question is: where is the PCX driver program located? Is there a way to hook into this program and use it in other programs to display graphics? If this is a possibility, then we could use the PC-Paint program, on our desktops, to create some great graphics screens for the 95LX.
And speaking of screen drivers: where is ANSI? Has anyone tried installing ANSI.SYS or NANSI.SYS, on their 95LX? What happened?
The biggest problem with the keyboard is its smallness, right? Other than that, it works fairly well. The usual programming techniques for reading keystrokes work for the 95LX.
However, many of the keys on the 95LX return an extended scan-code. If you're looking for a small challenge, how about writing a program that will capture and display the scan and ASCII code, as well as the name for all the keys, including those preceded by the <ALT>, <Shift>, <CTRL>, and <CHAR> key modifiers.
Command Line Switches and Arguments
One thing to keep in mind when writing software programs for the 95LX is that you might want to avoid using command line arguments or switches in your programs.
Programs which require parameters like Grep, Pkzip, Pklite, and so forth, can't be run directly from FILER. You either have to shell out to DOS, or you have to use a batch file to run the program. Both alternatives tend to be a nuisance.
Perhaps a better approach would be to write programs that prompt the user for any input, such as file names, when they start running. If your program has a lot of options, consider displaying these options before prompting the user for input.
How About TSRs?
Should we avoid writing Terminate-Stay-Resident programs?
For sure, the HP 95LX can handle TSR programs, but most novice users cannot. It is all too easy to start a TSR program from the FILER, by accident. When you quit the FILER, there will be a hole in the computer's memory where the FILER was. The unsuspecting user could be headed for a crash.
Choosing the Best Programming Language
I suspect that Assembler is the best language for the HP 95LX. It will let you make the most of limited disk space and, if you know what you're doing, it should also give you the fastest running programs.
If you don't know Assembler, but do know "C," consider using the Spontaneous Assembly Library from BaseTwo Software, 11 East 200 North, Orem, UT 84057; 800-277-3625).
Spontaneous Assembly contains over 700 different functions, written in assembler, and callable by C- sounding names.
Oh Say Can You C?
The next most appropriate programming language would have to be C.
I have been using Turbo C 2.0 for the past month to write several game programs for the HP 95LX. TC2.0 works well and yields reasonably small executable files. Borland's extensions to ANSI-C, such as "cprintf()" and "window()" also work on the HP 95LX and produce fast screen updates.
HP recommends Microsoft C and Assembler. All of the examples and working code in the Developers' Pac were apparently written using MS C 5.1 and MASM.
If you want to write SystemManager-compliant programs, today, you are almost obliged to write them in MS-C. System-Manager-compliant programs let the user run your program and then switch, via a blue-key, to the built-in applications such as MEMO or 1-2-3.
In my first attempt at writing a System-Manager-compliant program, I was unable to make use of the MS C routines in Turbo C. As time goes on routines for creating System-Manager compliant code may become available for free or as shareware in Turbo C, Turbo Pascal, and other languages.
System-Manager-compliancy is a most important subject and will be dealt with in future columns. Those of you who have some experience writing System-Manager-Compliant applications, be sure to share your experiences here
When compiling C programs, use the small memory model libraries. This will limit you to 64K for code and 64K for data.
Turbo Pascal 6.0
Turbo Pascal 6.0 has become my preferred programming language for the HP 95LX. It produces .EXE files that are smaller than comparable programs, written in Turbo C.
If you want to incorporate windows and fast screen updates in Turbo Pascal, be sure and use the CRT unit.
For windowing techniques, I have found that the WIN.PAS and WIN.OBJ files that come with Turbo Pascal 6.0 work very well and give the best bang for the buck. Other windows libraries work well, but they tend to add a lot of overhead.
Object Oriented Pascal and C++ are also useful, but, again, the extensions to the languages add overhead to the resulting .EXE files.
An Oldie-But-Goodie: Turbo Pascal 3
If you have a copy of Turbo Pascal 3.02A languishing in a file drawer, get it out, and dust it off. It will work almost out-of-box on the HP 95LX.
The version of Turbo Pascal 3.02A that I tried is for the IBMPC. It works on the HP 95LX like a charm. I used TINST to install the screen for "default mode" and to specify that the error message file could be found as C:TURBO.MSG.
I then used the Norton Utilities program to make one slight modification to TURBO.COM. At offset 006B hex, I changed 19 hex to 10 hex. This changes the screen size, for the built-in editor, from 25 lines to 16 lines. Then I used DIET.EXE to compress TURBO.COM to a 31K file; ported both TURBO.COM and TURBO.MSG to the 95LX and tried writing a simple program. The results were favorable. Even the normal writeln() function performed well. Screen updates were more than acceptable.
If you want a high level language that you can take with you in your palmtop, then Turbo Pascal 3.02a seems to be the smallest, "standard" compiler/ editor available.
How About Basic?
BASIC programs should also work on the 95LX, at least if they are compiled. I have not tried BASIC code on my 95LX. I'd be interested in the experience of others who have tried using this venerable language on their 95LX.
Getting Buggy: DEBUG
Finally, if you want the ultimate programming challenge, without sacrificing any disk space, you might try using DEBUG.COM. DEBUG.COM is available in the C:\_SYS subdirectory on the 95LX.
Past issues of PC Magazine contain many useful articles that will get you started using DEBUG.
If you have an older version of MASM, you should also find that it contains a copy of MAPSYM and SYMDEB. SYMDEB is the big brother to DEBUG. The documentation for this program will give you some more ideas of what you can do with DEBUG.
Let's Keep in Touch
As I mentioned at the beginning of the article, I look forward to your responses, answers, reflections and further questions.
To reach me you can: send a letter to Ed Keefe 314 SW Logan, Ankeny, IA 50021; send a message to me via CompuServe at 72377,1064; leave a recorded voice message at 515-248-7500; or send a letter or fax to Personalized Software, Programmer's Corner, PO Box 869, Fairfield, IA 52556; Fax: 515-472-1879.
Copyright © 2010 Thaddeus Computing Inc