     The following is a message that was posted in response to a question
about changing key assignments in WordStar 5.5:

#: 69423 S2/WordStar 5.5 Editor
    03-Sep-89  09:50:16
Sb: #69408-#Cursor keys
Fm: Ed Zollars (sysop) 72235,1234
To: Steve Gerber 72267,3332

Steve,
       The method hasn't really changed since WordStar 4.  The real problem is
that there are some jumps into the middle of the table we want to use (at
funtb1 and funtb2), but luckily given the exact changes you want to make we
don't have to worry about those, since all "expansion" of the table occurs
after funtb2.
       I'd put up a patch file, but I since it might be different between Rev.
C and Rev. A (though I doubt it), what I'll do is describe how to make the
patch.
       First, a quick summary of what the function key table looks like. Each
keystroke defined in there has a definition that consists of four
items--first, the number of bytes in the scan code that the BIOS will return
(always 2 for these keystrokes).  Next, the actual scan code that the BIOS
returns for that keystroke.  The number of bytes to translate the code into
comes next (for instance, you are going to map this key to ^ONI, you would
enter "03").  Finally comes the keystrokes you want to send to WordStar when
the function key is pressed.
       The definitions are packed together, one right after the other.  A
beginning length byte of 00 signals the end of this area of the table--if it
is followed by a nonzero value, that points to the continuation point of the
table (in the case of FUNTBL, it points to the MORPAT area).  If the next
value is 00, WS takes that to be the end of the function key table.
       What you want to do is patch the scan code table to contain the
following values:

       Key             Length  Scan Code       Length  Keystrokes
       Home            02      00,47           02      11,13
       End             02      00,4F           02      11,04
       ^Home           02      00,77           02      11,05
       ^End            02      00,75           02      11,18
       ^PgUp           02      00,84           02      11,12 *
       ^PgDn           02      00,76           02      11,03 *

The two marked with "*" are each one byte longer than the original code in
there.  All of the other entries are the same length.
       If all of them were the same length, you could look up the address in
PATCH.LST and simply patch over the old keystroke bytes with the ones you
want.  So, the first four patches are somewhat easy.
       The last two are more of a problem.  As I noted earlier, there are
"jumps" into the middle of the function key table from other parts of
WordStar.  Fortunately, the two that are changing size are below the last call
(the minor label funtb2)--if they had been above it, things would get much
more complicated.
       However, in this case it is somewhat simple since you can use the
autopatching facility to make your changes.  Fire up WSCHANGE, and select E
for patching.  Next select B to save the settings.  Give a name for this file
(FUNC.PAT is what I used) and *DON'T* save the entire user area. Simply ask
for the label FUNTBL and then hit <RETURN> when asked for the next label to
save.
       Exit WSCHANGE and go into WordStar.  From inside, open the FUNC.PAT
file as a *nondocument*.  You should find that someone on the next to the last
line of the file, the numbers listed begin to be all zeros--go to the point
that this happens and ^QY the rest of the line (beginning with the comma
before the first 00). Then delete the next line.
       Search for each of the first four scan codes listed in the table in the
previous message--when you find the code, look at the length byte immediately
following it.  For the first four, it should be "02"--if it is, you then set
the next two bytes to the value listed in the table (simply turn insert off
and type over them).
       Now for the last two changes--these have to be handled differently.
When you search for the scan code for ^PgUp, you will find your cursor in a
section that looks like this:

               00,84,01,17,02

The "01,17" (which is the keystrokes to be sent) has to be replaced with
"02,11,12".  Be certain not to change the ",02" following the "17".  Do the
same thing at the scan code for ^PgDn (replacing the codes with the
appropriate characters for ^QC.
       Save your changes, then go into WSCHANGE and read in the patch file.
       One warning--be SURE to back up your WordStar program file before
trying this patch.  If the function key table is fouled up, your WordStar may
do all kinds of nasty things that you won't like, so it's best to have the
original to fall back on.

