
This article is reprinted from the December 1990 edition of TechNotes/dBASE
IV.  Due to the limitations of this media, certain graphic elements such as
screen shots, illustrations and some tables have been omitted.  Where
possible, reference to such items has been deleted.  As a result,
continuity may be compromised.  

TechNotes is a monthly publication from the Ashton-Tate Software Support
Center.  For subscription information, call 800-545-9364.

The Luxury of Keyboard Macros
Rick Knight

Why is it that in EDIT mode, the Home and End keys take you to the
beginning and end of a character field while in BROWSE it takes you to the
first or last field?  This is a question of many a bewildered data entry
person.  The question naturally comes to mind after you've memorized a
certain key sequence that allows you to do your job in your sleep if you
have to.  I used to be a data-entry person way back when, and most times, I
felt I was comatose.

This nightmarish experience of my own past combined with some more recent
experiences brought to mind the need to play up the use of keyboard
macros.  Since some of you may be new to dBASE IV, you still may be a few
months away from discovering these little gems.  But they are definitely a
time saver.

Take the BROWSE/EDIT cursor movement differentials for example.  While it
is true that cursor keys perform differently with BROWSE, it would probably
not bother people if there was an equivalent key stroke to perform the same
field-oriented movement as is available in EDIT mode.  For the Home key,
use Ctrl-K while in BROWSE to move to the home position while in a
character field.  Ctrl-Backspace will also work but will issue a beep if
SET BELL is ON.  

The End key, on the other hand, is a little bit more stubborn since it
doesn't seem to have any control key equivalent.  Creating a keyboard macro
will fill the void here, working in every case except for that of the last
field in the record.  Follow the steps below while in BROWSE mode.

       Move your cursor to the home position in a calculated field.
       Press Shift-F10 and the Enter key to start macro recording.  When
    prompted to press the key that will call the macro, remember that
    macros are Alt key activated.  You have a choice of F1 through F9 or a
    combination of F10 plus a letter A-Z.  For this example, we'll use F1.
       Press the following  four keys in sequence: Tab, Left-Arrow,  Ctrl-A, 
    Ctrl-F
       Press Shift-F10 to end recording.  

Okay, try it out.  Press Ctrl-K to put yourself at the beginning of your
character field.  Now press Alt-F1.  It should work just like the End key
does in Edit.  But what a stretch for the hand with the Alt key way down on
the bottom row and most function key sets at the very top.

Well, now that you've accomplished the key simulation, you might as well
assign a redirection using ON KEY LABEL.  By doing this, you can re-assign
the End key to play your macro while in BROWSE.

It's been suggested in the past that once you get into keyboard macros and
key assignments, it's best to have a program called by the COMMAND = option
in your Config.db that will set all this up automatically when you enter
dBASE IV.  In addition to restoring macro or memory variable files from
disk, you could also assign system memory variables (like _peject = "NONE"
to prevent unwanted page ejects).  A simple program would appear like this:

RESTORE MACROS FROM MYMACS                      
ON KEY LABEL END PLAY F1

The ON KEY label reassignment will not affect the operation of the End key
while in EDIT or MODIFY COMMAND so all the better reason to customize your
dBASE IV installation.

One last and very important step.  You must save created macros before
ending your dBASE IV session.  This is done by the SAVE MACROS TO
<filename> command from the dot prompt or, if working from the Control
Center, via the Tools: Macros: Save library option.

Macros Are Everywhere

You may already be dismissing keyboard macros as a handy-dandy little
utility that will make editing more efficient.  But the fact is, keyboard
macros can be accessed from virtually anywhere:  The Control Center, Design
surfaces, Applications Generator and the Program or Memo editor.   Macros
can even be recorded and played back while in the on-line Help screens; any
place you can think of in dBASE IV that repetitive keystrokes would occur
would be a likely spot to record a macro.  Shift-F10 will allow you to
record them on-the-fly.

For example, a big beef of mine is to have to erase the contents of the
Forward search prompt from the Go To menu while in BROWSE, EDIT or MODIFY
COMMAND.  But I really don't have any reason to complain (other than
personal enjoyment) since I can easily construct a macro that pulls down
the Go To menu, selects the Forward Search option, deletes whatever
contents are there and allows me to enter new search criteria.
The three key strokes to do this would be very simple: Alt-G,  F,  Ctrl-Y.

In the Report design screen, many a developer has spent extra time just
replicating calculated fields in custom reports, cycling through the
different menus, moving through the different menu options, tabbing here,
spacing there.  Think of how much more efficient it would be to have a
macro that pulled down the Fields: Modify field option, bounce into the
expression area and position your cursor at a specific spot.  With the
user-input breaks that are built into macro recording, you can even enter
information of your own and resume with Shift-F10 to finish out a macro. 
In this case, the expression area could be closed and the two Ctrl-End
keypresses needed to return to the Design surface could be played.

While the Shift-F8 key can ditto fields selectively and the Carry forward
edit option in Screen design can make repetitive data entry easier, a macro
can also be of use here.  Say your boss is a stickler for words spelled
out.  You know, words and phrases like Association, Department, Mothers
Against Drunk Drivers, Unidentified Flying Objects, The Elvis Lives Forever
Fan Club.  Sometimes, you may not want this information copied from the
previous record  (is data entry ever that predictable?).  Macros can just
as easily be a literal text string as they can a sequence of control keys.

Macros are great in the Control Center too.  You can change back and forth
between commonly used catalogs, switch to a new directory, rename or copy a
file, import or export data (real handy if you have to relay data back and
forth to other platforms on a regular basis), change dBASE settings, even
load a new macro library.  

Regardless of your experience level with dBASE IV, we still have to trudge
through the same menus to get what we want, one way or another.  You might
be a person who types faster than they think, but a keyboard macro can
always do it faster.  So why not take advantage of that speed and
accuracy?  

The easy access to keyboard macro recording everywhere in dBASE IV (even
the on-line Help if you're so inclined), combined with the keyboard
reassignment capabilities of the ON KEY command can really let you
customize dBASE IV to your liking.  Give it a try and let us know how you
like it and how we can better implement this great functionality. 

