HOW TO USE: User Keys Make Built-In Applications Work Together

Develop user defined keys to coordinate the activities of two or more built-in applications, and to pause and prompt you for input. Learn how you can break through the ten-key barrier!

By Ed Keefe

Modern medicine has discovered three certain causes of headaches: drinking too much of certain beverages; listening to rap music; and having to enter too many keystrokes on a tiny computer keyboard. Fortunately, the HP 95LX offers a way to avoid the last headache -- User Keys.

User Keys, also known as system macros, are powerful tools to help you customize your 95LX. A good introduction to User Keys was given in Hal Goldstein's article," User Defined Function Keys: An Advanced Lesson for Beginners" (page 41 of the March/April 1992 issue). The HP 95LX User's Guide also describes them in a section called "Creating and Using User Keys" (see pages 21-14 to 21-20).

This article assumes that you're familiar with the basics of creating and using User Keys. Let's see some of the wizardry User Keys can perform.

Using HP CALC and MEMO to Pick a Winner

Using your 95LX to pick a Lotto number makes about as much sense as anything. You'll still lose, but you'll have fun doing it. This example shows how to develop a User Key that will coordinate the activities of HP CALC and MEMO.

The winning number in many Lotto games is a series of five numbers, each between 1 and 36. We'll develop a system that randomly selects a series of five numbers and displays them on your screen, prefaced by "Your lotto numbers are..."

[Editor's Note: The contents of all User Keys and Solver equation can be found in UFK.TXT .]

Entering the HP Calc Equation

On your HP 95LX press (HPCALC) (MENU) S to enter CALC's Solver. Highlight a blank field and press (F2) to go to the Solver Editor. Key in the following equation. (Note that the last line uses slightly different numbers.)






[Note that the five lines are almost identical. It is faster to type this formula into MEMO and then transfer it to the Solver Editor. After you enter the first line of the formula in MEMO, you can use Mark (F9) and Copy (F2) to put a copy of it on the four subsequent lines. Then modify the copies so the formula is correct. Finally, use Mark (F9) and Copy (F2) to copy the whole formula. Then go to HP CALC's Solver function, move the cursor to an empty line, and press (CTRL)-(F4) to Paste the formula into Solver -- Hal.]

This equation uses the RAN# function to generate a random number, the integer part of which is kept in the range 1...36 through the use of the Modulo function. Each of the five lines multiplies a random number by an even power of 10 (i.e. 1E2 means 102). All five lines are added together and assigned to "lotto."

When you've finished typing the equation, press (F9) (CALC) to show the Solve Calc screen. Press (F2) (lotto) twice to make sure the equation is working. (The number will always be 1 billion or larger. Don't worry that it doesn't look like a lotto number yet.) If it does not work, go back and make sure you entered the equation correctly. Next, press (MENU) File Save to save the file. Supply a file name if needed. Finally, press (MENU) Quit to exit HP CALC.

Creating the User Key

Now, press (SETUP) Char and highlight an empty field to enter your User Key. Press (F10) (Macro) to enter the User Key editor. If your keys are all assigned, you can copy a couple of them to MEMO to free up some room. Highlight the key you want to copy and press (F10) to enter the edit screen. Then Mark and Copy the contents of the key. Press (MEMO) (F4) to paste the contents of the key to MEMO for safe keeping. Then go back to Set Up and delete the contents of the key. Later you can copy it from MEMO and paste it back to the User Key contents field.

Once you're in the User Key editor, type the word Lotto in the Comment field and press (ENTER). Type the following macro in the Contents field.

(You can speed up your typing by using the [F6] key. For example, instead of typing {ENTER}, press (F6) and then (ENTER). However, with 95Buddy running, pressing (F6) (MENU) produces {F10}, not {MENU}. There may be some additional mappings that Buddy does. Switch Buddy off ((CTRL) (-) (-) if you're going to use (F6) to enter user key codes.

Also, if HP CALC is set to Options Format All, the period (.) between the two {F7} characters on line five below should be removed.)

Since it's often difficult to see spaces in a printed listing, I've used the tilde (~) in place of spaces. Wherever you see a ~, press (<Spacebar>).

Lastly, type in the User Key as running text. Don't press (ENTER) for a carriage return at the end of each line.













The first three lines of the User Key open the HP CALC program and choose the Solver option. The last saved file is opened automatically. The program finds the word "lotto", and solves the equation for the lotto number. It then copies this number to the clipboard and quits CALC altogether.

The next five lines open MEMO, jump to the end of the file and paste in the number from the clipboard. It then finds the decimal point in the number and marks and cuts everything from that point to the end of the line. Finally, it moves to the left, deleting commas as it goes.

The final four lines type out the phrase "Your lotto numbers are" before the number, and then inserts the appropriate spaces in the number.

European Readers: this macro assumes that CALC uses a period as a decimal point and commas as thousands separators. You'll need to switch to US formatting by pressing (SETUP) International Punctuation and select (.,,). (This is option A on US Palmtops. It may be something else on other versions of the 95LX.)

Using the Lotto Macro

Once the macro is keyed in, press (F10) to save the User Key and press (ESC) to return to the Set Up Menu. Press (CHAR) and the newly defined function key and watch what happens.

Lotto Number Screen:  Graphic

 If all goes well, you'll see the CALC program spring into action and your lotto numbers will appear in MEMO. If you want another set of numbers, just press (CHAR) F-key again. If it does not work, go back and make sure you entered the User Key correctly. [Editor's Note: If you win the lottery using this method, please send half your winnings to Ed Keefe, care of Richard Hall, care of Hal Goldstein.]

A User Key to Pause for Input

Here's an example of how to implement a "pause for input" feature. We'll do this by using two User Keys in tandem.

Suppose you wanted to produce a list of ALL the files on either the C drive or the A drive and view the list using FILER. You could exit to the DOS prompt to create the list with the following DOS command:

CHKDSK <drive>: /V > C:\FLIST.LST

(where <drive> is either A or C). This command runs the CHKDSK program in Verbose mode and uses the DOS redirection symbol (>) to send the output to the file, C:\FLIST.LST.

Here's a way to do this without having to go to the DOS prompt.

Create these User Keys

On your 95LX, open SET UP and press Char. Make sure you have space for at least two new User Keys. (In this example I'll use F2 and F3. You can use any two User Key fields you wish.)

Now enter the new User Key. Start by highlighting the desired User Key and pressing (ENTER). In the comment field, put the word Input and press (ENTER). Key the following macro into the contents field. (Remember, tildes (~) indicate blank spaces.)

{MEMO}{Ctrl-END}If Memo is not empty, save any text: quit and start over.{ENTER}On the line below, enter A or C ; then{ENTER}press ENTER and CHAR F3{ENTER}

If need be, change "F3" in the last line of this User Key so that it matches the name of your second User Key. When you've finished, press (F10) to save the macro.

This macro opens MEMO and goes to the last line of the file. It posts a reminder to save any work and start over. It then puts a prompt on the screen and waits for you to press the letter A or C for whichever drive you want to list.

Now go to the second macro field and key in this macro. (Remember, tildes (~) indicate blank spaces.)

{UP}{F9}{F3}{MENU}qn{MEMO}ECHO OFF{ENTER}CHKDSK~{F4}:~/V~>~C:\flist .lst{ENTER}{MENU}fs{BACKSP}{BACKSP} {BACKSP}{BACKSP}{BACKSP}{BACKSP} f.bat{ENTER}{MENU}q{FILER}{F5} c:\f.bat{ENTER}{ESC}{F4}{F3}y{F5} c:\flist.lst{ENTER}

Press (F10) to save this User Key and then press (ESC) to return to the SET UP menu screen.

This User Key Marks and Cuts the letter A or C and saves it in the clipboard. It then quits MEMO and restarts it with a blank screen. It writes a simple batch file, pastes the drive letter into the second line of the batch file, and saves the batch file as C:\ F.BAT. The User Key then quits MEMO and uses FILER to goto C:\ F.BAT. It runs this batch file and then deletes it. Finally the User Key displays the file C:\FLIST.LST, created by the batch file.

Running the User Keys

All applications but FILER must be closed for these User Keys to work properly. Press (CHAR) (F2) (or whatever F-key you've chosen) to start the first User Key. Then key in A or C and press (ENTER) (CHAR) (F3) (again, whatever F-key you've chosen). The screen will flash and, eventually, you'll see the words "Press any key to continue..." Press any key and the screen will flash and display the file listing. You can edit the file in MEMO or delete it with FILER.

File Listing Screen: Graphic

 (If you attempt to use these keys with one of the built-in applications open, the process will stop in the middle. You'll then have to press (ESC), close down all the built-in applications except FILER, delete F.BAT, and try it again.)

Once you see how this works, I'm sure that you'll be able to come up with macros to run other MS-DOS applications. The technique is especially well suited for those applications that require command line arguments, such as DEBUG, DIET, ZIP.COM, etc.

Some Limitations

User Keys are powerful tools that you can use to customize your HP 95LX. However, System Macros do have their shortcomings.

For instance, there is no "debugging mode" with User Keys. Since each User Key can have up to 255 keystrokes, the chances of getting one keystroke wrong is pretty high.

As a substitute for a "debugging mode," I suggest the following technique for building complicated User Keys. Instead of building one, large, User Key, build parts of it in separate, CHAR-Function keys. When each part is working just right, use the clipboard to copy and paste each part into the main User Key.

Overcoming the Ten-Key Barrier

As most of us already know, only ten macros can be active on the 95LX at any given time. This feature was probably incorporated into the 95LXbecause it only has ten function keys. Here's a way to get around that limitation.

User Keys are kept in the SETUP.ENV file in the C:\_DAT directory. If you want more than ten User Keys, you'll need to use alternate SETUP.ENV files. Here's one way to get another SETUP.ENV file.

First, use FILER to copy your existing SETUP.ENV to SETUP.OLD. The SETUP.OLD file will save all your original macros. Then press (SetUp) Char and delete any (or all) of the User Keys. You now have room to enter additional User Keys.

To reinstall your original macros, use FILER to rename SETUP.ENV to SETUP.NEW and rename SETUP.OLD to SETUP.ENV. You might even create a User Key to automate this process.

If this all sounds like too much work, read on.

Multi-Macro Manager

The FastAid Co. offers the Multi-Macro-Manager program (MMM) as an elegant way to overcome the ten key barrier. If you need more than ten User Keys, then you'll want to read on.

Multi-Macro Manager allows you to have up to 200 macros (User Keys). You can choose one macro from a list of macros and run it by pressing a single key on the number keypad.

Multi Macro Manager Screen:  Graphic

 Individual macros can be copied or moved from one set of macros to another, or to a different location within the same set of macros. Individual macros may also be deleted without using the SET UP program. New, empty sets of macros can be created and old sets can be deleted at the press of a key.

The disk also includes several sets of User Keys, created by those who have earned their MM (Master of Macros) degree.

MMM is a small MS-DOS program (under 15K bytes). It can be run from FILER. However, with the addition of a suitable loader program (two are supplied) the MMM program can pop-up on top of any built in application except 1-2-3.

If you'd like to save $5.00 on your registration fee, just include a printed copy of five of your own User Keys. (If they are complicated, please include a brief description of what they're supposed to do.) With your permission, these macros may be included in subsequent releases of MMM with your name attached to them.

This is a special offer to readers of The HP Palmtop Paper. It will be withdrawn two months after the publication of this article. Don't delay.

Until next time, Happy Palmtopping.