home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / zsys / znode-12 / a / fatctsrc.lbr / OUTCAT.PZS / OUTCAT.PAS
Encoding:
Pascal/Delphi Source File  |  1993-06-12  |  10.1 KB  |  341 lines

  1. {        This file is OUTCAT.PAS                          }
  2. {        Part of the FATCAT program                       }
  3. {        But can also be run separately                   }
  4. {        24 December, 1985                                }
  5.  
  6. {        Version 2.1                                      }
  7. {        28 December, 1985 improved Com line parsing      }
  8. {           and help screen                               }
  9.  
  10. {        Modified for compatibility with PluPerfect       }
  11. {        DateStamper 31 December, 1985                    }
  12.  
  13. {        Modification 12 January, 1986                    }
  14. {        Fixed bug that was causing only one file to be   }
  15. {        found on unambiguous file names                  }
  16.  
  17. {        Version 2.3                                      }
  18. {        Modified  for XCAT-format option                 }
  19. {        14 January, 1986                                 }
  20.  
  21. {        Version 2.4                                      }
  22. {        Fixed various bugs, allow print to file feature  }
  23. {        i.e. XCAT now handles last file correctly        }
  24. {        3 June, 1986                                     }
  25.  
  26. {        Author:  Steven M. Cohen                         }
  27.  
  28. {        COMPILATION INSTRUCTIONS                         }
  29. {        To be compiled under C option                    }
  30. {        Set Start address to $2173                       }
  31. {        Set End Address to $AE00                         }
  32. {        After compilation:                               }
  33. {        Load OUTCAT.COM with debugger                    }
  34. {        Change address 0101 to 70h                       }
  35. {        Read the file SAVECOM.COM in with offset 7000H   }
  36. {        Move the region from 7100H to 7190H to 20E2H     }
  37. {        Read the file OUTCAT.TXT to add HelpScreen text  }
  38. {        to com file                                      }
  39. {        Save 91 OUTCAT.COM                               }
  40. {        This procedure saves the command line before     }
  41. {        Turbo trashes it                                 }
  42. {        SEE OUTCAT.ZEX FOR AN example of how to          }
  43. {        automate process (requires DSD debugger          }
  44. {        but can probably be done with DDT, etc.          }     
  45. {$V-,X-}
  46.   Const
  47.     Version = 24;
  48.     Blank = $20;
  49.     HelpLoc = $5a80; {First free half-page above prog area}
  50.   type
  51.  
  52.     Key        = String[23];
  53.     Str2       = String[2];
  54.     Str11      = String[11];
  55.     Str12      = String[12];
  56.     Str14      = String[14];
  57.     Str15      = String[15];
  58.     FileNamStr = String[16];
  59.     Str20      = String[20];
  60.     Str23      = String[23];
  61.     Tail       = String[127];
  62.     Str255     = String[255];
  63.  
  64.  
  65. Devices = (Screen,Printer,DiskFile);
  66.  
  67. Parameters = record
  68.   CatLibs,
  69.   CleanUpMode,
  70.   DateStamp,
  71.   ReIndex  : Boolean;
  72.   PrinterOffSet,
  73.   UserToCatalog,
  74.   MaxUser       : Byte;
  75.   FileRoot      : String[8];
  76.   ProgDr,
  77.   DriveToCatalog,
  78.   RegNdxDr,
  79.   LibNdxDr,
  80.   RegCatDr,
  81.   LibCatDr,
  82.   DNIxDr,
  83.   TempCatDr      : String[2];
  84. END;
  85.  
  86. CommandSet = record
  87.   SMask : String[11];
  88.   HighDisk,
  89.   LowDisk : Integer;
  90.   ConfigFileName: String[16];
  91.   Device: Devices;
  92.   Header : String[60];
  93. END;
  94.  
  95. FileRec = Record
  96.   DiskN: String[3];
  97.   UserN: String[2];
  98.   LibrN: String[8];
  99. END;
  100.  
  101. OutPutline = Record
  102.   FileN: String[12];
  103.   Info:  Array[0..2] of FileRec;
  104. END;
  105.  
  106.  
  107. VAR
  108.    SetUp                                       : Parameters;
  109.    Choice                                      : Char;
  110.  
  111.     {****** TURBO - ACCESS CONSTANTS ***********}
  112. CONST
  113.       maxDataRecSize = 28;
  114.       MaxKeyLen      = 23;
  115.       PageSize       = 32;
  116.       Order          = 16;
  117.       PageStackSize  = 9;
  118.       MaxHeight      = 6;
  119.  
  120. PROCEDURE ErrorMessage(ErrNo: Integer);FORWARD;
  121.  
  122.  {$IFCACCESS.BOX}
  123.  
  124. OVERLAY PROCEDURE EM(ERRNO: INTEGER);
  125.   VAR EMsg: StrING[80];
  126.   CONST EraseMsg :String[32] = 'Erase Unneeded Files from Disk.';
  127.  
  128. BEGIN
  129.   Case ErrNo of
  130.     $1,$4:    EMsg := 'File does not exist or not open';
  131.     $90,$91,$99: EMsg:=
  132.     'File Damaged or Truncated.  Erase File & Start Over';
  133.     $F0: EMsg := 'Disk Full. Change Configuration or '+EraseMsg;
  134.     $F1: EMsg := 'Directory Full.  '+EraseMsg;
  135.     $F2: EMsg :=
  136.     'Wow! You have exceeded theoretical limit of FATCAT file size.';
  137.     $F3: EMsg := 'File disappeared.  Did you switch disks?'
  138.     Else
  139.     BEGIN
  140.       Str(ErrNo:3,EMsg);
  141.       EMsg := 'Error #'+Emsg;
  142.     END;
  143.   END;{CASE}
  144.   WriteLn(EMsg);
  145. END; {EM}
  146.  
  147. PROCEDURE ErrorMessage; {Was forward declared}
  148. BEGIN
  149.   EM(ErrNo);
  150. END;
  151.  
  152.  {$IGETKEY.BOX}
  153.  
  154.  
  155.   CONST
  156.     KeyL : Array[Boolean] of Integer = (15,23);
  157.     KeyWord: Array[Boolean] of String[7] =
  158.                  ('REGULAR','LIBRARY');
  159.  
  160. TYPE
  161.     Index      = record
  162.       IxF      : IndexFile;
  163.       FN       : Str14;
  164.     END;
  165.  
  166.  
  167.  
  168.  VAR
  169.    MemTop                                      : Integer absolute $0006;
  170.    UpArrow                                     : Char absolute $0164;
  171.    DownArrow                                   : Char absolute $0165;
  172.    RightArrow                                  : Char absolute $0166;
  173.    LeftArrow                                   : Char absolute $0167;
  174.    CRTLines                                    : byte absolute $0169;
  175.    CSet                                        : CommandSet;
  176.    X                                           : Char;
  177.    CmdIndic                                    : Byte absolute $80;
  178.    NewTail                                     : Tail absolute $20e2;
  179.    Chained                                     : Boolean;
  180.    Ix                                          : Array[Boolean] of Index;
  181.    DNum,Code,K                                 : Integer;
  182.    Akey                                        : Key;
  183.    FileName                                    : Str12;
  184.    Smallest,Largest                            : Str11;
  185.    DiskNumber                                  : String[3];
  186.    DiskNames                                   : Array[0..999] of String[8];
  187.    OutF,Outfil                                 : text;
  188.    NOOfFiles                                   : Array[Boolean] of Integer;
  189.    UniqueNames,
  190.    I,Page,Line,TotalFiles                      : Integer;
  191.    User                                        : Byte;
  192.    Library                                     : Boolean;
  193.    DNIxName                                    : String[14];
  194.    PageLim                                     : Integer;
  195.    PaginationOn,Interrupted,Quitting           : Boolean;
  196.    Offset                                      : String[20];
  197.    ChainFile                                   : file;
  198.    Outline                                     : Outputline;
  199.    LastName                                    : Str11;
  200.    OutFName: String[16];
  201.  
  202. CONST
  203. Default : Parameters =
  204.        (  CatLibs       : True;
  205.           CleanUpMode   : True;
  206.           DateStamp     : False;
  207.           REINDEX       : False;
  208.           PRINTEROFFSET : 0;
  209.           UserToCatalog : 63;
  210.           MaxUser       : 15;
  211.           FileRoot      : 'MASTER';
  212.           ProgDr        : 'A:';
  213.           DriveToCatalog: 'B:';
  214.           RegNdxDr      : 'A:';
  215.           LibNdxDr      : 'A:';
  216.           RegCatDr      : 'A:';
  217.           LibCatDr      : 'A:';
  218.           DNIxDr        : 'A:';
  219.           TempCatDr     : 'A:');
  220.  
  221.  
  222. {$IOUTCAT.IN1}
  223. {$IOUTCAT.IN2}
  224.  
  225. PROCEDURE ReadConfigFile(ConfigFileName:FileNamStr);
  226. VAR ConfigFile: File of Parameters;
  227. CONST  UsingDefaultsMsg: String[17] = '. Using Defaults.';
  228.  
  229. BEGIN
  230.   Move(Default,SetUp,SizeOf(SetUp));
  231.   Assign(ConfigFile, ConfigFileName);
  232. {$I-}
  233.   Reset(ConfigFile);
  234.   If IOResult <> 0 then
  235.       Writeln ('File ',ConfigFileName,' not found',UsingDefaultsMsg)
  236.   else
  237.   BEGIN
  238.     Writeln('Reading ' + ConfigFileName);
  239.     Read(ConFigFile,SetUp);
  240.     If IOresult <> 0 then
  241.       Writeln('Error in File ',ConfigFileName,UsingDefaultsMsg);
  242.     Close (ConfigFile);
  243.   END;
  244.  {$I+}
  245. END;
  246.  
  247.  
  248. BEGIN
  249.  
  250.   {Initialization and set up}
  251.   StackPtr := MemTop - $26;
  252.   RecurPtr := StackPtr - $400;
  253.   HeapPtr := $B00F;
  254.  
  255.   Clrscr;
  256.   CRTINIT;
  257.   Chained := (CmdIndic >= $80);
  258.   Mem[Addr(NewTail)] := Mem[Addr(NewTail)] and $7f;
  259.   Interrupted := false;
  260.   Quitting := False;
  261.   PaginationOn := True;
  262.   CSet.Header := '';
  263.   FillChar(CSet.SMask,12,'?');
  264.   Mem[Addr(CSet.Smask)] := 11;
  265.   CSet.Device := Screen;
  266.   If Chained then
  267.   BEGIN
  268.     GetSearchSpecs(CSet);
  269.     GetOutfile;
  270.     If CSet.Device = Printer then
  271.     BEGIN
  272.       Write('Header (<CR> for none):');
  273.       Readln(CSet.Header);
  274.     END;
  275.   END
  276.   Else
  277.   BEGIN
  278.     Choice := 'O';
  279.     CSet.ConfigFileName := 'STANDARD';
  280.     Write('OUTCAT - output module of the FATCAT system - ');
  281.     Writeln('V. ',version div 10,'.',version mod 10);
  282.     ParseCommandLine(NewTail,CSet);
  283.     CSet.ConfigFileName := CSet.ConfigFileName + '.CFG';
  284.     ReadConfigFile(CSet.ConFigFileName);
  285.     Writeln;
  286.   END;
  287.     Ix[False].FN := SetUp.RegCatDr + SetUp.FileRoot + '.RCX';
  288.     Ix[True].FN  := SetUp.LibCatDr + SetUp.FileRoot + '.LCX';
  289.     DNIxName    := SetUp.DNixDr   + SetUp.FileRoot + '.DNX';
  290.   InitIndex;
  291.   Smallest := CSet.Smask;
  292.   Largest := CSet.SMask;
  293.   For I := 1 to 11 do
  294.     If CSet.SMask[I] = '?' then
  295.     BEGIN
  296.       Smallest[I] := ' ';
  297.       Largest[I] := '~';
  298.     END;
  299.   Offset := '';
  300.   If CSet.Device = Printer then
  301.     For I := 1 to SetUp.PrinterOffset do
  302.       Offset := Offset + ' ';
  303.   FillNamesArray;
  304.   Page := 0;
  305.   CASE CSet.Device of
  306.     DiskFile :  UsrOutPtr := Addr(FileEcho);
  307.     Printer  :  UsrOutPtr := Addr(Echo);
  308.     Screen   :  UsrOutPtr := Addr(PolledConOut);
  309.   END; {Case}
  310.   SelectOutput(OutF);
  311.  
  312.   {Actual output all done in this call}
  313.   DisplayMach;
  314.  
  315.   {Return to default states and exit}
  316.   UsrOutPtr := ConOutPtr;
  317.   Writeln;
  318.   If CSet.Device = Diskfile then
  319.     Close(OutFil);
  320.   If Chained then
  321.   BEGIN
  322.     Write('Hit any key.');
  323.     Read(Kbd,X);
  324.   END
  325.   Else
  326.     If Not Quitting then
  327.     BEGIN
  328.       Delay(2000);
  329.     END;
  330.   CRTEXIT;
  331.   If Chained then
  332.   BEGIN
  333.     Mem[$80] := Mem[$80] or $80;
  334.     Assign(ChainFile,SetUp.ProgDr + 'FATCAT.COM');
  335.     Execute(ChainFile);
  336.   END;
  337. END.
  338.  
  339.     Mem[$80] := Mem[$80] or $80;
  340.     Assign(ChainFile,SetUp.ProgDr + 'FATCAT.COM');
  341.     Execute(