2CBHFT  HF-GECOVER UTILITYHF-  HF-GEfor IBM PC, XT, or ATHF-  HF-GE(PRINT SORTED DIRECTORY)HF-  HF-  November 1, 1984  Dan Daetwyler  Route 5, Box 518A  Springdale, AR 72764  (501) 756-0212 - COVER UTILITY  GContents  G Introduction ................................................. 1  G Operation .................................................... 2  G Source Code .................................................. 3  G Patching ..................................................... 6  G Modifications ................................................ 7  G Rights and Data .............................................. 8 - Contents ii - COVER UTILITY  GE-INTRODUCTIONHF-HF-  Just what you always needed! Yet another redundant, dupli-  cative, and space occupying utility... Hopefully, this fills a  niche left open in the array of PC-DOS utilities. This one sorts  and formats the directory data and prints it so its "just right"  to fit inside the diskette envelope. You have to provide your  own paper cutter... the utility does the rest.  The program runs under PC-DOS Versions 1.x, 2.x, or 3.0 and will  operate on any normal configuration. It does expect the IBM or  Epson MX80 printer (or equivalent), but should be easily modified  to apply to any printer that offers "condensed" print and 8 lines  per inch line spacing.  It has two known limitations. It ignores hidden files, and if  you're a Version 2.0 or later user and have implemented the  "tree" directory paths with multiple directories on a  diskette, only the "root" directories will be printed. Since  the "path" logic seems primarily aimed at fixed disk, and this  utility is directed towards diskettes, these limitations should  not effect most users. - Introduction 1 - COVER UTILITY  GE-OPERATIONHF-  Simply place the diskette containing COVER.COM in a diskette  drive, and enter the command: COVER.  The utility will prompt with a console message asking which drive  contains the diskette to be listed, so enter the single character  drive designator appropriate (A-G). No colon or carriage return  will be required. The program will then prompt for the title you  wish to appear on the top line of the list. A 37 character  field is provided. If you do not want the title, simply hit the  "Enter" key, and the top line of the listing will be blank except  for the date, and the diskette label (if it has one). When the  first listing is complete, the utility will loop back and ask  for another drive. This iterative process will continue until  you respond with an "Escape" key to the drive request prompt.  Exit is then made to the DOS.  Note that although the utility prints two envelope covers per  page, forms will be advanced to the "top of form" position in  effect when the utility was started. The printer will also be  restored to "power up" status. If you use Control-Break to exit  the utility, this will not be true, so you'll have to manually  re-aline and reset your printer. - Operation 2 - COVER UTILITY  GE-SOURCE CODEHF-  For those of you who do not wish to modify or extend COVER, this  section will contain little of value. If your need is only that  of trying to "fit" COVER to a different printer, read the section  on "patching" first.  The program is composed of seven separately assembled  modules: COVER, COTITL, COFREE, COSCAN, COSORT, COPRNT, and  COENDP. The listings are commented, but I'll include a few words  on each of the modules.  COVER is the main control module, and contains the major  loop. Its first action is to preset the printer to 8 lines per  inch, condensed print, and a 44 line page. If you have a  "different" printer, you may need to change the control stream  defined at SETPRT. The final zero in the control stream is not  sent to the printer, but marks the end of string for DOPRT.  Next, COVER checks for the DOS Version. The return from the 30H  call (which is valid on release 1.x), is the release and  version numbers under V2.0 of DOS. On prior releases it returns  a zero. This code simply sets a switch that will be tested  later. The "default" drive is then determined and saved, and  finally, the number of drives on the configuration is  determined.  COVER then prompts for the drive letter for the drive  containing the diskette to be listed. The single character input  is first checked for an "Escape" (all done, so get off), and then  the drive character is verified for a "legal" drive  designator. The prompt starts the main loop, which ends after  all processing is done for one diskette. COVER then calls  GETTTL (Get Title), GETFRE (Determine free space on  diskette), SCAN (Load all directory entries into an internal  stack), SORT (Sequence the stacked entries), and PRINT (which  formats and prints the stacked entries).  When the Escape character is sensed, COVER resets the  "default" drive to its value on entry, conditionally forces out  one more "page" to restore the paper to the true top of forms,  and then resets the printer to "power up" status. The control  string for the latter is at RESPRT so the "different" printer  users may modify that string if required.  GETTTL is a primitive module which solicits a "title" from the  user. 37 characters are allowed, and the standard DOS  function is used to get this string. Null titles are  permissible. The DOS function is also used to get the system  date. DECMAL is a local subroutine that converts the content  of the AL to two decimal digits in the AH and AL and then  stores them in the area defined by the DI register. This code  section also makes an attempt to get a "label" for the diskette.  If the attempt is successful, the title "Label: ", and the actual  label are placed in the title line. - Source Code 3 - COVER UTILITY  GETFRE computes the "free" space available on the diskette and  places the ASCII decimal result in the title line. This  program is the reason COVER checked for the DOS Version. V2.0  provides a "nice" function that will give the free space  directly, but does not allow you to gain addressability to the  File Allocation Table (FAT). V1.x did not have this feature, but  did provide addressability to the FAT. Since this program was to  be used in both environments, this code has two paths. The code  following the version test is for V2.0 (or later). Code  starting at the label VERS1 is that process necessary to  determine free space under the older versions of DOS. VCOM  marks the point where the two paths re-join. If you're only  running V2.0, you can decrease the size of the utility by  removing the code from the instruction "JMP VCOM" to the  instruction before that labeled VCOM. Finally, CONVRT is a  public subroutine that converts the AX/DX content to a max of a  seven digit number, leading zero suppressed, and places the  result at the area pointed to by the DI register.  SCAN does the normal DOS function calls to "find" an all  "wild card" file name. This process repeats until the entire  directory has been scanned. The result is placed in a stack and  a pointer to the start of the entry is placed in a pointer  list. The format of the stack entries is the file-name.typ  followed by a zero byte, and then the four byte file size  field from the directory. Since the data transfer area (DTA)  has not been reset this module finds it input in the default  DTA at 80H in the program prefix.  SORT is a simple "bubble" sort of the stacked entries, but is  driven from the pointer list. Yes, I know a shell sort is  faster, but for a max of 224 entries, an old fashioned bubble  uses less memory!  PRINT simply uses the sorted pointers to form the final  output. The title line has already been formed by the prior  modules. The local subroutine PRTENT uses CONVRT to format the  file sizes. Four columns will "fit" within the print size  required, so PRINT initially computes column length. An inner  and an outer loop controls the print process. The inner loop  prints one entry each execution, and is executed four times per  line. The outer loop is cycled once per entry in a single  column.  The source module COENDP includes no code. This module  simply provides addressability to the memory above the program  code. V2.0 provides this function in a much "cleaner" manner,  but since this utility is to run on either Version, this  subterfuge is necessary.  That's a very quick "walk through" for the code, but  together with the source comments, it should provide  sufficient information for any extensions or modifications you  may choose to make. Key the source in, and assemble the seven  modules. The Link control stream is also included in the  listings. Be very sure that the module COENDP occurs last in - Source Code 4 - COVER UTILITY  the control stream, as shown in the listing. Otherwise you'll  be stacking directory entries over some of the code.  For those of you who are not familiar with "COM" files, ALL  segment registers are preset by the operating system to the same  value, so although you see no code for setting the DS and ES  segment registers, they contain the same value as the CS and SS  at program initiation so change is not required. The stack is  automatically allocated at the "top" of the segment (64K) the  program is loaded to, so no stack establishment is  required. Finally, the established stack is initialized so  that a "NEAR" return at end of program will return you to DOS  correctly, so long as the CS register has not been changed.  This program uses the 20H termination call, but could do a simple  near RET with the same result.  Link will provide console messages saying that there is no  stack segment (that's right), and that there is one error (that's  false). This response is normal when you're preparing a "COM"  file. If you get more errors or other indications, you'd better  re-check your work. Now you're ready to run EXE2BIN, and  then rename the resultant file (COVER.BIN) to COVER.COM.  That's all it takes. - Source Code 5 - COVER UTILITY  GE-PATCHINGHF-  If you have a printer other than those normally supported, and if  your printer can be set for compressed print, 8 lines/inch, and  variable page length, then you can probably "patch" COVER to suit  your printer. Patching is simple. Bring up COVER under DEBUG,  by entering:  DEBUG COVER.COM  Now enter a D 100, and debug will display (in hex) the data found  at offset 100H in the data segment. Since COVER is a COM file,  the code segment is the data segment. You'll notice two 12 byte  strings at location 103H and 10FH, followed by a 4 byte string at  location 11BH. The first string is the control codes necessary  to set your printer to the following condition:  Compressed print  44 Line Page  8 lines/inch print  Check your printer manual and find out the set of codes required,  and then use debug to key them into the area beginning at 103H.  Be sure the string ends with a zero byte (null), and that no  nulls are required in your command string. Your command string  must be contained within 11 bytes plus the null byte to end the  string.  At location 10FH, you need to code a similar string, but this  time it is the control codes necessary to cause your printer to  restore itself to your "normal" settings. Again, this string  must terminate with a zero byte. At location 11BH, code the  control codes necessary to cause your printer to "restore" or  advance the form to the next "top of form". Typically, this is a  single byte, but even so, it must be followed by at least one  zero byte.  Having made those changes, simply enter the W command, and Debug  will write back you changed file. Try it and see if it works.  If it does not, you'd better recheck your changes (you were  working with a backup, weren't you?), and your printer manual. - Patching 6 - COVER UTILITY  GE-MODIFICATIONSHF-  The original "COVER" has been modified to remove a few bugs. A  correction was made to stop the utility from going into an  endless loop when you attempted to list a diskette containing  zero or one files.  When V3.0 arrived, I found that the version check was faulty, and  version 3.0 was considered to be the equivalent of V1.x. Ugh.  That has been fixed.  V3.0 also fixed a DOS "bug" that's been around "forever", so it  now became possible to print the diskette label on the cover page  title line, and that provision was "picked up". To provide space  for this addition, the "title" was reduced from 40 to 37  characters.  V3.0 supports high capacity diskette drives, which now makes it  likely to have free space in the million byte or above ranges.  Cover didn't like numbers greater than 6 digits, so that has been  expanded to permit 7 digit numbers. The new drive permits a  diskette to have up to 224 directory entries in the root  directory. That really doesn't "fit" on the old cover page,  soooooo..... COVER will now use its normal cover page for  directories containing up to 132 entries. Over that, it will  simply keep printing until it runs out of directory entries.  You'll have to fold the page to stuff it in the envelop. Yes,  COVER is smart enough to get to the true top of a physical page,  before it starts one of the "extra long" cover pages. - Modifications 7 - COVER UTILITY  GE-RIGHTS AND DATAHF-  Cover has been formally declared "Public Domain", which gives you  full rights for use, copy, modification, destruction(?),....  This version is also placed in "Public Domain". If you wish to  be placed on a mailing list for notification of future versions  (if any), and a moderately friendly reaction if you turn up  trouble, the price is $5, to be sent to the address given below:  This program is covered under no warranty of any kind, and the  writer is not liable for any damages, direct or indirect,  suffered through its use, or through inability to use this  program.  Dan Daetwyler  Route 5, Box 518A  Springdale, Arkansas 72764  501-756-0212 - Rights and Data 8 2CBHFT - Rig