In the last issue, we mentioned several programs that enhance the keyboards of the 95LX and 100LX. In general, these programs involve some set up work up front to prevent a lot of keystrokes later on.
On the HP 100LX there is one built-in program that may let you save a lot of keystrokes. The program is called PUSHKEYS.COM and it's located in the D:\BIN subdirectory. However, if you try to find PUSHKEYS.COM with FILER, you won't. It's a hidden file. You have to go to DOS, press (CTRL)(123), and type the command DIR D:\BIN /AH to reveal the file's name.
[Editor's Note: PUSHKEYS.COM [ON DISK] didn't make it into the non-English versions of the HP 100LX due to lack of space. By special arrangement with HP, we've included the file on this month's HP Palmtop Paper On Disk.]
What is Pushkeys?
PUSHKEYS is a TSR (Terminate and Stay Resident) program that reads the contents of a .MAC file created by the 100LX System Macros application and sends each macro keycode to the keyboard buffer. PUSHKEYS sends all the macros in a particular .MAC file to the keyboard buffer, starting with F1 and going through F10. This has the same effect as sequentially running all the macros in a .MAC file.
You can create a macro as you normally would, either by recording it or by keying it in, in the System Macros application. Once the macro has been created, you can save it to a separate file. There are several advantages to using PUSHKEYS:
Before experimenting with Pushkeys, back up all your files and be prepared for anything.
Installing Pushkeys
Before you can use PUSHKEYS, it must be installed as a TSR. To do this press (&...) to go to Application Manager and press (MENU) Application Terminate All... (F10). This will terminate all applications. At the DOS prompt type d:\bin\pushkeys /i and press (ENTER) to install PUSHKEYS. Then type 100 and press (ENTER) to restart System Manager.
If you want PUSHKEYS available at all times, you can put the above two commands at the end of your AUTOEXEC.BAT file.
d:\bin\pushkeys /i
100
Then whenever you reboot the machine PUSHKEYS will be installed automatically.
Example: Using Pushkeys to Get a Directory Listing
To illustrate the use of PUSHKEYS let's create a simple macro file, TEST.MAC, that runs two slightly different versions of the DOS DIR command.
First save your current set of macros. Go to the System Macros application in AppManager and press (MENU) File Save As... and give your current set of macros the name OLD .MAC and press (ENTER). Then press (MENU) File New to clear all the macro fields.
Move the cursor to the Fn+F1: macro press (ENTER) and type DIR OF D: in the Description field. Move to the Contents field and key in the following macro. (SHORTCUT: In the Contents field, press (F6) followed by the key you want to enter and the 100LX automatically types it in for you (e.g., press (F6) (MENU) and {MENU} is keyed in for you.):
{Enter}{More}{Menu}AL{Filer}{Menu} OD#100#DIR D:\/S>C:\DIR_D.TXT{Enter} #100#DIR D:\ /S /AH >>C:\- DIR_D.TXT {Enter}#100#EXIT{Enter}{Memo}{Menu}FOC:\ DIR_D.TXT{Enter}
Press (F10) (MENU) File Save As... C:\TEST.MAC (ENTER) (ALT) Quit to save the macro file and quit. [Editor's Note: If you make corrections to the TEST.MAC file be sure that you save it again as C:\TEST.MAC. The System Macros application Save command will save the file in its default directory as C:\_DAT\TEST.MAC and leave the C:\TEST.MAC file unchanged.]
Use MEMO to create a batch file to make Pushkeys run TEST.MAC. The batch file contains one line:
@d:\bin\pushkeys c:\test.mac
Save the file as C:\TESTPK.BAT. (Lotus 1-2-3 interferes with this example. Before testing these files, save the spreadsheets you're working on and quit 1-2-3.)
The macro above starts with an {Enter} to return to System Manager after the batch file has been run from FILER. It then closes all applications and goes to DOS to run two slightly different versions of the DIR command. The directory listings are redirected and saved in a file named D_DIR.TXT, which is loaded into MEMO at the end of the macro.
The #100# command tells PUSHKEYS to pause for 100 time units (100 * 1/18.2 ~= 5 secs). There are a couple of occasions where this delay is needed. For example, if your macro starts a graph in CALC, an ordinary macro may feed in the next keystroke thereby interrupting the process. Another time this happens is when a macro uses Calc and 1-2-3 together. During the time that it takes to get 1-2-3 loaded, a pushkey macro would keep feeding in keystrokes, thereby getting things out of sync. The #100# (or larger) delay prevents this from happening. On my machine the first delay works fine, but subsequent delay times seem to be ignored. Test this use of Pushkeys by going to FILER, highlighting TESTPK.BAT and pressing (ENTER). Your screen will hop from FILER to DOS to AppManager, then back to DOS, and finally end up in MEMO. Scroll to the bottom of the file in MEMO and you'll find the listing for the hidden PUSHKEYS .COM file.
Example: Make a Hotkey to Launch a DOS Program
Some DOS programs require that you close all applications and terminate System Manager before you can run them. Examples include ACT!.EXE, PROHLP.EXE, and all TSR programs.
The number of keystrokes to accomplish this is not great. All you have to do is press (&...) (MENU) Application Terminate All... (ENTER) type the name of your program at the DOS prompt and press (ENTER). To get back to System Manager just type 100 and press (ENTER).
Here is a one-button hotkey solution using PUSHKEYS, courtesy of Raan Young. It involves creating a System Macro that runs the following files:
RUNPGM.BAT . . . . . runs a DOS program
CALLPK.BAT . . . . . runs PUSHKEYS
DOSPGRM.MAC . . . . . system macro file
In MEMO create and save a file called RUNPGM.BAT which contains two lines:
c:\dospgm c:\<switches>
100
DOSPGM represents the file name of the DOS program you want to run and <SWITCHES> represents any command line arguments and/or switches that the program might need. I've used C:\ as the path for DOSPGM and DATAFILE. If your program is located elsewhere, use the appropriate path.
While in MEMO, create and save another batch file called CALLPK .BAT which contains the lines:
d:\bin\pushkeys c:\dospgm.mac
exit
This batch file activates the Pushkeys program and tells Pushkeys to use the DOSPGM.MAC file as a data file.
Now go to the System Macros application to save your current macro file. Press (MENU) File New to clear out any macros, and press (ENTER) to bring up the FN+F1 edit screen. Enter the following macro definition:
{Enter}{Menu}q{More}{Menu}at{F10} #100#c:\runpgm.bat{Enter}
To save this macro file press (F10) (MENU) File Save As... C:\DOSPGM.MAC (ENTER). Press (F7) (Clear) and (ALT) Quit to clear the macro file and quit.
Finally, to make this a one-button solution, create a macro that will run CALLPK.BAT. Go to the System Macro application and type the following macro definition in the edit screen of the macro you wish to use (I used Fn+F3 for this example):
{More}{Menu}AL{Filer}{F5} c:\callpk.bat{Enter}{Enter}
Then, quit the macro application and press (Fn)-(F3) to invoke the macro you just created.
Here's what will happen:
starts up AppMgr
{Menu}aL
close all open applications
{Filer}
starts Filer
{F5}c:\callpk.bat{ENTER}
goes to the CALLPK batch file
{Enter}
runs the CALLPK.BAT file
get past the "press any key..." prompt
{Menu}q
quit FILER
{More}
start AppManager
{Menu}at
terminate all applications
{F10}
answer OK
#100#
tells PUSHKEYS to wait 100 (1/18 seconds each)
c:\runpgm.bat
runs the RUNPGM batch file
starts DOS program
c:\datafile
any data or switches used by the DOS program
100
runs SysMgr again the DOSPGM ends
Going to the Max with PUSHKEY
Macros One of the advantages of using PUSHKEYS is that it will let you create a 2,550 keystroke macro without using the "chain" command. PUSHKEYS does this by consecutively reading the function key macros in the .MAC file from Fn+F1: through Fn+F10: giving it 10 fields of 255 characters.
To see how this works you can create a macro file in which Fn+F1 contains the following in its Contents field:
{Enter}{Memo}The quick brown fox jumps over the lazy dog.
Then use the COPY and PASTE keys to fill in the rest of the Contents field with several copies of the "The quick brown fox jumps over the lazy dog."
Then COPY everything in Fn+F1's Contents field, except the leading {Enter}{Memo}, and paste it into the Contents fields for Fn+F2 through Fn+F10. Save this file as C:\TEST2.MAC.
Next, create a batch file, TEST2.BAT, which contains the line:
@pushkeys test2.mac
Run this Pushkey example by going to FILER, highlighting test2.bat, and pressing (ENTER). MEMO should start and you'll see "the quick brown fox jumps over the lazy dog" over and over and over and over and...
Some DOS applications need all the available System RAM. You have to terminate System Manager to run these, and this means you have no System macros available to automate these DOS programs. Pushkeys is ideal for these applications because it is a DOS application (a small TSR) that will work in both SysMgr and DOS. It will take some time to learn how to use the program and get it to behave "just right". However, if you run the same DOS application a couple of times a day, the time and trouble of mastering Pushkeys will pay off in the long term.
For those who want to test their mettle with really big macros that flip back and forth between System Manager and DOS, Pushkeys may be the only way to go.
There is no equivalent program for the HP 95LX. However, if you're intrigued with the idea of automating the HP 95LX, and you're willing to work with the DEBUG program, I'd suggest that you take a look at a previous Programmer's Corner article (pages 42-48 of The HP Palmtop Paper, July/Aug 1993).
[Editor's Note: Ed has also written Multi-Macro-Manager, a program for the 95LX that breaks the 10 User Key limit and will do many of the things that PUSHKEYS will do with compiled macros. See Product Index, page 55.]
Use KEYBEZ to Support Other Languages
KEYBEZ is another built-in program that affects the keyboard. KEYBEZ allows you to change the complete character set you use on the 100LX.
This is what allows the 100LX to support languages other than English, such as Greek, Russian, Turkish, French, Spanish, Italian and the Scandinavian languages. The fonts, currency time and date formats for each language set are found in .KIT and .FON files in the D:\BIN directory along with the program KEYBEZ.COM.
These different character sets are referred to as "code pages," the default code page for the 100LX is 850. You can use KEYBEZ to change to another code page, like 866 for Russian, but there is a catch. Lotus 1-2-3 only supports code page 850 and you may have difficulty displaying or printing with any other code page. When you save a file then change to another code page you may not be able to recover that file until you change back to the original code page. Also, your printer will have to be able to support the code page you are using.
KEYBEZ enhances the 100LX by giving you access to the special characters and symbols for other languages, and it will let you switch between English and another language. [For more information on using KEYBEZ see pages 7-23 through 7-27, Appendices E and F in the 100LX User's Guide.]
Bug in the HP 100LX Solver Program
There's an old saying among programmers: "Only trivial programs are free of bugs." The corollary has to be: "If a program is bug-free, it's trivial."
It's taken me the better part of a year, but I've finally convinced myself that the 100LX's SOLVER program is NOT trivial. I've found a bug.
The bug involves several of the new Solver functions available only on the 100LX. These functions are mentioned on pages 30-7 and 30-10 of the HP 100LX User's Guide. The book does not provide any examples showing how to use them. These functions are as follows:
SIZEC(CFLOW)
returns the number of cash flows in the CFLOW.CFL file.
FLOW(CFLOW,row)
returns the value from the first column and the specified row, in the CFLOW.CFL file.
#T(CFLOW,row)
returns the group size of the cash flow in the CFLOW.CFL file.
SIZES(STAT)
returns the number of items in the STAT.STA file. (This is not to be confused with the SIZES(range) function that returns the same thing as LENGTH (range) in a spreadsheet.)
ITEM(STAT,row,column)
returns a value from the given row and column in the STAT.STA file.
The new functions are supposed to make Solver behave more like the HP 19BII calculator and in most cases they do. However, in one case they fail completely.
THE BUG
If you use these functions too many times in succession, for example inside a SIGMA(,,,,) loop, you risk losing all your work in progress. Here's what happens on my machine.
When I run the following equation:
SIGMA (cntr,1,15,1,
SIGMA(cntr,1,SIZES(STAT),1,ITEM(STAT,cntr))
)=Crash
The equation attempts to compute the sum of the items in the STAT.STA file 15 times. (STAT.STA is the file created when you enter a list of numbers into the List Stat application in HP CALC. In this example it contained 8 or 9 values.)
Running this equation I get the error message, "Too many files are open". At that point, I am unable to close any files that are open. The HP 100LX will ask if I want to continue. If I say "Yes", and try to open FILER, I get the same "Too many files are open" message. The only recourse is to press CTRL-ALT-DEL and force the computer to reset itself. Of course, all new data in open applications (1-2-3, MEMO, etc.) will be lost.
The same lock-up happens if I substitute the corresponding Cash Flow functions, SIZEC(CFLOW) and FLOW(CFLOW,cntr), in place of SIZES(STAT) and ITEM(STAT,cntr) in the above equation. Even setting "FILES=200" in the CONFIG.SYS file does not seem to have any effect.
Caution: If you want to test this out on your 100LX, save everything before attempting to solve for "Crash". Be prepared to reset the 100LX with (CTRL)-(ALT)-(DEL).
THE WORKAROUND
Instead of using the new SIZES(STAT) or SIZEC(CFLOW) functions, use the Lotus 1-2-3 function LENGTH(RANGENAME). Instead of List Stat, define a Range in the current open 1-2-3 worksheet. Likewise, use Lotus function RCLCELL(Rangename,row,column) instead of Solvers ITEM(), #T(), or FLOW() functions.
One advantage of this work around, using Lotus in conjunction with Solver, is that your Solver equations will work on both the HP 100LX and the 95LX.
HP Corvallis has been notified of the bug. They are looking into it. In the meantime I tip my hat to the programmers at HP. Who else would have built "redundancy" into a pocket computer by including both HP CALC and Lotus 1-2-3?
Until next time, Happy Porting.