;
                                 ZDKCOM.COM                                   

             Size (recs) CRC   Version    Author/Latest Issue      Disk
               2k (14)   B2FD  1.3        Carson Wilson 4/89       Z3COM14

  1- Syntax  2- Usage  3- Notes  4- Example of Use                            


   ZDKCOM compiles an  ASCII text file into  a *.ZDK file  of key macros which 
ZDENSTAL will install in  ZDE.   It also converts  an existing ZDK file into a 
text file with the extension ZDT.   It allows you to create, edit, and re-edit
complicated key  macros  with  a  full-featured word processor -  ZDE itself - 
instead of the backspace-only line editor in ZDENSTAL.
:1



   Syntax:  ZDKCOM <ufn>.ZDT  -->  converts text file to ZDK overlay

            ZDKCOM <ufn>.ZDK  -->  converts overlay to ZDT text file  
:2


Usage:

     Use ZDE in NONDOCUMENT mode  to type  a file that looks like what you see 
when you use the K option of ZDENSTAL,  substituting lower case "n" or "q" for 
the No Repeat and Quiet option indicators <N> and <Q>:

  qThis line would be for key 0 in Quiet mode.^M
  nThis line would be for key 1 in No Repeat mode.^M

  This line would be key 3, with key 2 unassigned.
  n<This line would appear in angle brackets.>^M^M^M
  The line above, key 4, prints with two blank lines following it.
  q"This is in quotes, but no carriage return at the end."
  "This line is ^P^BMacro Key 7^P^B with embedded boldface codes."^M
  q^VThis line turns insert on before printing the line.^A^A^A^A_^F^D_^M
  n <Key 9 not installed>^A^A^A^A


   ...and so on.  Lines correspond to the number keys in  0 to 9  order,  with 
blank lines for unassigned keys.  Do NOT embed control codes.  Type everything
in ASCII.   For instance,  to  underline, type out '^P^Swords underlined^P^S'.  
It's  a good idea to  make hard  carriage returns visible  by toggling them on 
with the  ^OD command.   ZDKCOM accepts trailing spaces as part of  the macro, 
even though you can't see them,  so,  if you  don't want them,  make sure each 
line is terminated by a hard carriage return.

     Individual key macro strings may  not exceed  127 bytes  in the ZDK file, 
though they may in  the ZDT text  file, since ASCII representations of single-
byte control  codes require two  bytes,  and option  flags  and  slashes don't 
contribute to the length of the string.

     The total of  all strings may  not exceed 498 output bytes.   This is two 
bytes less than allowed by ZDE and ZDENSTAL, but,  under the program's present 
logic,  it would require  an inordinate amount  of code to make those last two 
bytes available.   If you really need  them,  add them  to the  ZDK  file with 
ZPATCH or  any other patcher,  locate the  last string-length byte,  and add 2 
(in hex) to it.
:3

ZDKCOM Notes:

   a. Vs 1.3 fixes a bug which caused ZDKCOM to abort if  the  value in memory
      at BCNTR was greater than  7E hex.   It also fixes a bug which prevented 
      switching  from  decompile  to compile  mode with the ZCPR "GO" command. 
      Lines  in .ZDT files  now end in CRLF instead  of  just  CR  for  easier 
      viewing.  Status reports and helps screen have also been improved.



   A ZDK file is a data structure four records long.   The first two bytes are
an ID  number which  ZDENSTAL  checks to ensure that it  is  working  with the 
correct  version.   The current number,  0250h,  is valid  for  several recent 
versions of ZDE.

   These two bytes are  followed by  up  to  ten  strings,  each preceded by a 
string-length byte which ZDE uses to index the string's location.  Each string
is limited by the size of a buffer in ZDE to 127 bytes.

     An empty string is indicated by  a string-length byte of 00h.   After the 
last byte of the last string,  the remainder of  the 512 bytes are filled with 
00h.

     It is  a peculiarity of ZDKCOM that  it needs to  write two null bytes at 
the end of the  file,  which means that  it will accept only 498 bytes for the 
total length  of all  strings (512, less two ID bytes,  less 10  string-length 
bytes, less these two more) rather than the 500 that ZDE and ZDENSTAL allow.



   When you  look  at  the  key  macro  buffer  of ZDE using  the K option  of 
ZDENSTAL, you see something that looks like this:

  <0><Q>This line would be for key 0 in Quiet mode.^M
  <1><N>This line would be for key 1 in No Repeat mode.^M
  <2><>
  <3>This line would be key 3, with key 2 unassigned.
  <4><N><This line would appear in angle brackets.>^M^M^M
  <5>The line above, key 4, prints with two blank lines following it.
  <6><Q>"This is in quotes, but no carriage return at the end."
  <7>"This line is ^P^BMacro Key 7^P^B with embedded boldface codes."^M
  <8><>
  <9><>



   The numbers down the side and the  option indicators <N>,  <Q>,  and <> (no 
option) are supplied by ZDENSTAL.  The ZDT text file version of the same macro
keys would omit the  string numbers and no option indicators,  and convert the 
<N> and <Q> to simple lower case 'n' and 'q'.   If you  need lower case 'n' or 
'q' as the first character of a key macro, just precede it with a slash, which 
will be ignored.

   ZDKCOM recognizes blank lines as unassigned keys.  These produce an "error"
message when invoked by ZDE.

   ZDE recognizes  a No Repeat option if the high bit is set on the first byte
of the macro string after the length byte,  and a Quiet option if the high bit 
is set on both of the first two bytes of the string.



   The translation procedure from text to overlay requires:

a. Enter two-byte ID string 02h 50h in output file.

b. Enter 00h to save a place for a string length byte.

c. Check for "n" or "q" as first three bytes of new string and  add 80h to the
   next byte or next two bytes input as required.

d. Read in the rest  of the string byte  by byte  and output  each byte to the 
   output file.   If "^" appears in the string,  drop it and subtract 40h from 
   next byte to make it into a real control character.  If "/" appears, ignore
   it  and print  the next character literally.   "/^" prints  "^" rather than 
   turn the character following the carat into a control code, and "//" prints
   a single slash.  A single input slash is ignored.



e. When the CRLF pair is  encountered in the input text file,  convert it to a
   00h place  marker for the length of  the  next  string.   Get the number of 
   bytes output in the last string and write it to the position of the string-
   length byte at the head of the preceding string.

f. When the text file's ^Z EOF is encountered, fill the remainder of the total
   512 bytes with 00h and close the files.

   When converting  ZDK overlays to  ZDT text files,  the procedure is more or 
less reversed.   ZDKCOM converts the string  length bytes to  CRLF pairs,  the 
control code bytes  to two-byte ASCII strings '^c',  and finishes off the file 
when all strings are accounted for by inserting an EOF ^Z.

   In addition, ZDKCOM has error checking for file opening and closing and for
individual and overall string length, and it reports activity to keep the user
from thinking the  program has hung,  though the  counters  on the  screen are 
otherwise meaningless.



  The structure of the  four-sector ZDK file in  CP/M  is  so  similar  to the 
eight-sector MS/DOS version that you can use ZDKCOM,  along with a patcher, to 
create a ZDK file for installation in ZDE12, the MS/DOS version of ZDE.   Make 
up the ZDT file as you would for CP/M,  then patch the second ID byte from 50h 
to 60h and add four records of nulls.
:4


Example of Use:

   For a quick demo,  write the following out to a file  <ufn>.ZDT (no leading
spaces).  Run 'ZDKCOM <ufn>.ZDT'.   Then load the resulting ZDK  file into ZDE 
with the command 'ZDENSTAL ZDE <ufn>.ZDK.'

  q^C^C^C^E^E^E^E^E^[^E
  q^[b^[0^Qs^X^[=^M1^[= 1^S^V ^D^[!0^[1^Qb^B^Ku
  ^[=^M0^V^I^V^B^G^[![^[0^X
  ^[=^M0^T^B^N^[0^X
  q^P^[^P^I^P^K^P^[9
  q^V^KrA0:LH.FMT^M
  q^G^G^G^G^X
  q<not installed>^A^A^S
  q<not installed>^A^A^S
  q^KrHEADER^M



Key macro 0    measures off one full page if  the top margin is 0 and the page 
               length is  58 lines.   Adjust  for different  page  lengths  by 
               adding or subtracting ^E's.  I use this macro to move from line
               1 of a page to line 1 of the next page.  I then use key macro 9
               to read in  a page header from  a separate  file  that contains 
               nothing but the properly spaced header text with a  #  in place 
               of the  page number.   I search for # with a ^Qf and replace it 
               with the appropriate page numbers.

Key macro 1    softens and reforms  a paragraph  by removing the hard carriage 
               returns from the ends  of each line.   

Key macro 2    changes  a document in  flush left block format (like this one) 
               to indented paragraph form, and...

Key macro 3    changes it back again.



Key macro 4    embeds my  DIABLO 1610-compatible printer's code  for setting a 
               left margin in  column 11 (^K=0Bh) in the document.   If I want 
               another margin I add or subtract from 0Bh and  overwrite the ^K
               with the  appropriate control character.   Substitute  your own 
               printer's set left margin code for this one.

Key macro 5    reads in  a previously prepared letterhead stored  as LH.FMT on 
               drive/user A0.

Key macro 6    removes four spaces  or characters from  the  beginning of each 
               line,  used  to remove  line  numbers  from  the beginnings  of 
               messages in modem capture files.

Key macro 7    <uninstalled>

Key macro 8    <uninstalled>

Key macro 9    reads in a previously prepared page header stored as HEADER.
