home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB34.ZIP / DIR401.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-03-15  |  46.6 KB  |  1,616 lines

  1.  
  2. {
  3.                   ╒═════════════════════════════════════════╕
  4.                   │    DIR401.PAS      -         3/15/86    │
  5.                   ╞═════════════════════════════════════════╡
  6.                   │  Written by Wes Meier (76703,747) and   │
  7.                   │  dedicated to the Public Domain.  The   │
  8.                   │  directory read code was written by     │
  9.                   │  Neil J. Rubenking.                     │
  10.                   ╘═════════════════════════════════════════╛
  11. }
  12.  
  13. {$V- }
  14.  
  15. Type
  16.  
  17.   Regtype     = Record
  18.                   Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Flags : integer
  19.                 End;
  20.   HalfRegtype = Record
  21.                   Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh : byte
  22.                 End;
  23.   filename_type = string[64];
  24.   files_type = String[16];
  25.   Str255 = String[255];
  26.   Time = Record
  27.            Hours,Min,Sec,Hundreths : Byte
  28.          End;
  29.   DOW = (Sun,Mon,Tue,Wed,Thu,Fri,Sat);
  30.   Date = Record
  31.            Month,Day : Byte;
  32.            Year : Integer;
  33.            DayOfWeek : DOW
  34.          End;
  35.  
  36. Const
  37.  
  38. {regs is defined as a typed constant in order to get it in the code segment}
  39.  
  40.   Regs : regtype = (Ax:0;Bx:0;Cx:0;Dx:0;Bp:0;Si:0;Di:0;Ds:0;Es:0;Flags:0);
  41.   Max_Entries = 3500;
  42.   DayName : Array [DOW] Of String[9] = ('Sunday','Monday','Tuesday',
  43.                                         'Wednesday','Thursday','Friday',
  44.                                         'Saturday');
  45.   CurStart = 0;
  46.   CurEnd = 12;
  47.   On = True;
  48.   Off = False;
  49.  
  50. Var
  51.  
  52.   SaveRegs                    : regtype;
  53.   HalfRegs                    : halfregtype absolute regs;
  54.   x,y,entries,fore,back,bord,
  55.   fore_hi,attrib              : integer;
  56.   filepath                    : filename_type;
  57.   files                       : Array [0..Max_Entries] of Files_Type;
  58.   ok,Reading,Sort_Flag,
  59.   List_Dta,List_Act           : boolean;
  60.   ch,choice                   : char;
  61.   cpi16                       : string[20];
  62.   sx,sy,diskstr,disk          : Str255;
  63.   ft                          : text;
  64.  
  65. Procedure Set_Cursor(start_line, End_line : integer);
  66.   var
  67.     result : regtype;
  68.  
  69.   Begin
  70.     with result do
  71.       Begin
  72.         ax := $100;
  73.         cx := start_line shl 8 + End_line;
  74.         intr($10,result)
  75.       End
  76.   End; { Proc Set_Cursor }
  77.  
  78.  Procedure Cursor(On : boolean);
  79.    Begin
  80.      if On
  81.        then
  82.          Set_Cursor(CurStart,CurEnd)
  83.        else
  84.          Set_Cursor($20,$20)
  85.    End; { Proc Cursor }
  86.  
  87. Procedure Pad_Left(var x       : Str255;
  88.                        padchar : char;
  89.                        num     : byte);
  90.  
  91.   var k : byte;
  92.  
  93.   Begin
  94.     for k := 1 to num do x := padchar + x;
  95.     x := copy(x,length(x) + 1 - num,num)
  96.   End; { Proc Pad_Left }
  97.  
  98. Procedure Pad_Right(var x       : Str255;
  99.                         padchar : char;
  100.                         num     : byte);
  101.   Begin
  102.     while length(x) < num do x := x + padchar;
  103.     x := copy(x,1,num)
  104.   End; { Proc Pad_Right }
  105.  
  106. Procedure Check_Pos;
  107.     Begin
  108.       if WhereX > 70 then WriteLn;
  109.       if WhereY > 23
  110.         then
  111.           Begin
  112.             GotoXY(15,25);
  113.             Write('Press any key to continue (* or Q to quit) ...');
  114.             Repeat Until KeyPressed;
  115.             Read(Kbd,choice);
  116.             choice := UpCase(choice);
  117.             if choice = 'Q' then choice := '*';
  118.             ClrScr;
  119.             GotoXY(1,1)
  120.           End { if }
  121.     End; { Proc Check_Pos }
  122.  
  123. Procedure AtEnd;
  124.   var c : char;
  125.  
  126.   Begin
  127.     GotoXY(20,25);
  128.     Write('End of Directory. Press any key to continue ...');
  129.     Repeat Until Keypressed
  130.   End; { Proc AtEnd }
  131.  
  132. Procedure Get_File;
  133.  
  134.   type
  135.     Dir_Entry   = Record
  136.                     Reserved : array[1..21] of byte;
  137.                     Attribute: byte;
  138.                     Time, Date, FileSizeLo, FileSizeHi : integer;
  139.                     Name : string[13]
  140.                   End;
  141.  
  142.  var
  143.    RetCode   : byte;
  144.    Filename  : filename_type;
  145.    Buffer    : Dir_Entry;
  146.    Attribute : byte;
  147.  
  148.  Procedure CheckNulls;
  149.    var v : integer;
  150.  
  151.    Begin
  152.      for v := 1 to 12 do
  153.        Begin
  154.          if files[entries][v] = #0 then files[entries][v] := ' '
  155.        End { for v }
  156.    End; { Sub Proc CheckNulls }
  157.  
  158.  Procedure Disk_Trns_Addr(var Disk_Buf);
  159.    var
  160.      Registers : regtype;
  161.  
  162.   Begin
  163.     with Registers do
  164.       Begin
  165.         Ax := $1A shl 8;                 { Set disk transfer address to  }
  166.         Ds := seg(Disk_Buf);             { our disk buffer               }
  167.         Dx := ofs(Disk_Buf);
  168.         msdos(Registers)
  169.       End
  170.    End; { Proc Disk_Trns_Addr }
  171.  
  172.   Procedure Check_Max;
  173.     Begin
  174.       if entries > Max_Entries
  175.         then
  176.           Begin
  177.             WriteLn;
  178.             WriteLn;
  179.             WriteLn(#7,'You have reached the Maximum number of entries!');
  180.             WriteLn('Your DIR.DAT remains intact. You',#39,'ll have to create');
  181.             WriteLn('another DIR.DAT file on a different data disk.');
  182.             WriteLn;
  183.             WriteLn('DIR Halted.');
  184.             Halt
  185.           End { if }
  186.     End; { Proc Check_Max }
  187.  
  188.   Procedure Find_Next(var Att:byte;
  189.                       var Filename : Filename_type;
  190.                       var Next_RetCode : byte);
  191.     var
  192.       Registers  : regtype;
  193.       Carry_flag : integer;
  194.       N          : byte;
  195.  
  196.     Begin {Find_Next}
  197.       Buffer.Name := '             ';      { Clear result buffer }
  198.       with Registers do
  199.         Begin
  200.           Ax := $4F shl 8;                 { Dos Find next function }
  201.           MsDos(Registers);
  202.           Att := Buffer.Attribute;         { Set file attribute     }
  203.           Carry_flag := 1 and Flags;       { Isolate the Error flag }
  204.           Filename := '             ';
  205.           if Carry_flag = 1
  206.             then
  207.               Next_RetCode := Ax and $00FF
  208.             else
  209.               Begin                         { Move file name         }
  210.                 Next_RetCode := 0;
  211.                 for N := 0 to 11 do FileName[N+1] := Buffer.Name[N]
  212.               End { else }
  213.         End  { with }
  214.     End; { Proc Find_Next }
  215.  
  216.   Procedure Find_First (var Att: byte;
  217.                         var Filename: Filename_type;
  218.                         var RetCode_code : byte);
  219.  
  220.     var
  221.       Registers  :regtype;
  222.       Carry_flag :integer;
  223.       Mask, N    :byte;
  224.  
  225.     Begin
  226.      Disk_Trns_Addr(buffer);
  227.      Filename := Filename + chr(0);
  228.      Buffer.Name := '             ';
  229.      with Registers do
  230.        Begin
  231.          Ax := $4E shl 8;                { Dos Find First Function }
  232.          Cx := Att;                      { Attribute of file to fine }
  233.          Ds := seg(Filename);            { Ds:Dx Asciiz string to find }
  234.          Dx := ofs(Filename) + 1;
  235.          MsDos(Registers);
  236.          Att := Buffer.Attribute;        { set the file attribute byte  }
  237.  
  238.                                          { If error occured set, Return code. }
  239.  
  240.          Carry_flag := 1 and Flags;      { If Carry flag, error occured }
  241.                                          { and Ax will contain Return code }
  242.          if Carry_flag = 1
  243.            then
  244.              RetCode_code := Ax and $00FF
  245.            else
  246.              Begin
  247.                RetCode_code := 0;
  248.                Filename := '             ';
  249.                for N := 0 to 11 do FileName[N+1] := Buffer.Name[N]
  250.              End { else }
  251.        End  {with}
  252.     End; { Proc Find_First }
  253.  
  254.   var
  255.     attribyte : byte;
  256.  
  257.   Begin { Primary block of Get_File }
  258.     filename := filepath;
  259.     attribyte := 0;
  260.     Find_First(attribyte,filename,Retcode);
  261.     If Retcode = 0
  262.       then
  263.         Begin
  264.           if Reading
  265.             then
  266.               Begin
  267.                 entries := entries + 1;
  268.                 Check_Max;
  269.                 files[entries] :=Filename;
  270.                 Pad_Right(files[entries],#32,12);
  271.                 files[entries] := files[entries] + disk;
  272.                 CheckNulls;
  273.               End { if Reading }
  274.             else
  275.               Begin
  276.                 Write(filename);
  277.                 Check_Pos;
  278.                 if choice = '*' then Retcode := 1;
  279.                 choice := ' '
  280.               End { else }
  281.         End; { if Retcode }
  282.  
  283.     { Now we Repeat Find_Next Until an error occurs }
  284.  
  285.     Repeat
  286.       Find_Next(attribyte,filename,Retcode);
  287.       if Retcode = 0
  288.         then
  289.           Begin
  290.             if Reading
  291.               then
  292.                 Begin
  293.                   entries := entries + 1;
  294.                   Check_Max;
  295.                   files[entries] :=Filename;
  296.                   Pad_Right(files[entries],' ',12);
  297.                   files[entries] := files[entries] + disk;
  298.                   CheckNulls;
  299.                 End { if Reading }
  300.               else
  301.                 Begin
  302.                   Write(filename);
  303.                   Check_Pos;
  304.                   if choice = '*' then Retcode := 1;
  305.                   choice := ' '
  306.                 End { else }
  307.           End { if Retcode }
  308.     Until Retcode <> 0;
  309.     if not Reading
  310.       then
  311.         if choice <> '*'
  312.           then
  313.             AtEnd
  314.   End; { Proc Get_File }
  315.  
  316. Procedure TimDat(var timestr, datestr, daystr :Str255);
  317.   Procedure GetTime(Var T:Time);
  318.     var regs : HalfRegType;
  319.  
  320.     Begin
  321.       With Regs,T Do
  322.         Begin
  323.           AH := $2C;
  324.           MsDos(Regs);
  325.           Hours := CH;
  326.           Min := CL;
  327.           Sec := DH;
  328.           Hundreths := DL
  329.        End { with }
  330.     End; { Sub Proc GetTime }
  331.  
  332.   Procedure GetDate(Var D:Date);
  333.     var
  334.       Regs : HalfRegType;
  335.  
  336.     Begin
  337.       With Regs,D Do
  338.         Begin
  339.           AH := $2A;
  340.           MsDos(Regs);
  341.           Month := DH;
  342.           Day := DL;
  343.           Year := 256 * CH + CL;
  344.           DayOfWeek := DOW(AL)
  345.         End { with }
  346.     End; { Sub Proc GetDate }
  347.  
  348.   Var
  349.     T1 : Time;
  350.     D1 : Date;
  351.     s1 : string[5];
  352.  
  353.   Begin { Proc TimDat Main }
  354.     GetTime(T1);
  355.     GetDate(D1);
  356.     With T1 Do
  357.       Begin
  358.         timestr := '';
  359.         str(hours,s1);
  360.         Pad_Left(s1,'0',2);
  361.         timestr := s1 + ':';
  362.         str(min,s1);
  363.         Pad_Left(s1,'0',2);
  364.         timestr := timestr + s1 + ':';
  365.         str(sec,s1);
  366.         Pad_Left(s1,'0',2);
  367.         timestr := timestr + s1
  368.       End; { with T1 }
  369.     With D1 Do
  370.       Begin
  371.         datestr := '';
  372.         str(month,s1);
  373.         Pad_Left(s1,'0',2);
  374.         datestr := s1 + '/';
  375.         str(day,s1);
  376.         Pad_Left(s1,'0',2);
  377.         datestr := datestr + s1 + '/';
  378.         str(year,s1);
  379.         datestr := datestr + s1;
  380.         daystr := DayName[DayOfWeek]
  381.       End  { with T1 }
  382.   End; { Proc TimDat }
  383.  
  384. Procedure Color(fr,bk,bd : integer);
  385.   Begin
  386.     TextColor(fr);
  387.     TextBackground(bk);
  388.     Port[$03d9] := bd
  389.   End; { Proc Color }
  390.  
  391. Procedure UpperCase(var x : Str255);
  392.   var i : integer;
  393.  
  394.   Begin
  395.     for i := 1 to length(x) do x[i] := UpCase(x[i])
  396.   End; { Proc UpperCase }
  397.  
  398. Procedure Sort;
  399.  label
  400.    B, C, D;
  401.  
  402.  var
  403.    i,j,k,l,m,n : integer;
  404.    t           : files_type;
  405.  
  406.  Begin
  407.    Cursor(Off);
  408.    Write ('Sorting');
  409.    n := entries;
  410.    m := n div 2;
  411.    While m > 0 do
  412.      Begin
  413.        Write ('.');   { Just to show that something's going on.... }
  414.        j := 1;
  415.        k := n - m;
  416. B:     i := j;
  417. C:     l := i + m;
  418.        if files[i] >= files[l]
  419.          then
  420.            Begin
  421.              t := files[i];
  422.              files[i] := files[l];
  423.              files[l] := t;
  424.              i := i - m;
  425.              if i >= 1 then goto C
  426.            End; { if }
  427. D:     j := j + 1;
  428.        if j <= k then goto B;
  429.        m := m div 2
  430.      End; { while m }
  431.    WriteLn;
  432.    Cursor(On)
  433.  End; { Proc Sort }
  434.  
  435. Procedure Sort_By_Num;
  436.   var i : integer;
  437.  
  438.   Begin
  439.     if Sort_Flag
  440.       then
  441.         Begin
  442.           Sort_Flag := False;
  443.           for i := 1 to entries do
  444.             files[i] := copy(files[i],5,12) + copy(files[i],1,4)
  445.         End { if }
  446.       else
  447.         Begin
  448.           Sort_Flag := True;
  449.           for i := 1 to entries do
  450.             files[i] := copy(files[i],13,4) + copy(files[i],1,12)
  451.         End; { else }
  452.     Sort
  453.   End; { Proc Sort_By_Num }
  454.  
  455. Function Exist(filenam : files_type) : Boolean;
  456.   var
  457.     f : file;
  458.  
  459.   Begin
  460.     Assign(f, filenam);
  461.     {$I- }
  462.     Reset(f);
  463.     {$I+ }
  464.     Exist := (IOresult = 0);
  465.     close(f)
  466.   End; { Function Exist }
  467.  
  468. Procedure Init;
  469.   var
  470.     fil    : text;
  471.  
  472.   Begin
  473.     if not Exist('dir4.cfg')
  474.       then
  475.         Begin
  476.           Assign(fil,'dir4.cfg');
  477.           ReWrite(fil);
  478.           {
  479.             Create the default parameters
  480.           }
  481.           fore := Green;
  482.           back := Black;
  483.           bord := Black;
  484.           fore_hi := Yellow;
  485.           cpi16 := #27 + 'P'; { Default to the Epson/IBM string }
  486.           WriteLn(fil,fore);
  487.           WriteLn(fil,back);
  488.           WriteLn(fil,bord);
  489.           WriteLn(fil,fore_hi);
  490.           WriteLn(fil,cpi16)
  491.         End { if }
  492.       else
  493.         Begin
  494.           Assign(fil,'dir4.cfg');
  495.           Reset(fil);
  496.           ReadLn(fil,fore);
  497.           ReadLn(fil,back);
  498.           ReadLn(fil,bord);
  499.           ReadLn(fil,fore_hi);
  500.           ReadLn(fil,cpi16)
  501.         End; { else }
  502.     close(fil);
  503.     Sort_Flag := False;
  504.     color(fore,back,bord);
  505.     ClrScr;
  506.     window(27,9,60,21);
  507.     gotoXY(1,1);
  508.     WriteLn('╒════════════════════════╕');
  509.     WriteLn('│                        │');
  510.     WriteLn('│        DIR 4.01        │');
  511.     WriteLn('│                        │');
  512.     WriteLn('│      by Wes Meier      │');
  513.     WriteLn('│                        │');
  514.     WriteLn('│       March 1986       │');
  515.     WriteLn('│                        │');
  516.     WriteLn('╞════════════════════════╡');
  517.     Write  ('│');
  518.     TextColor(fore_hi);
  519.     Write('FOR PUBLIC DOMAIN ONLY');
  520.     TextColor(fore);
  521.     WriteLn('│');
  522.     Write  ('╘════════════════════════╛');
  523.     window(1,1,80,25)
  524.   End; { Proc Init }
  525.  
  526. Procedure Read_Data_From_Disk;
  527.   var
  528.     dir_dat : text;
  529.  
  530.   Begin
  531.     if not Exist('DIR.DAT')
  532.       then
  533.         Begin
  534.           Assign(dir_dat,'DIR.DAT');
  535.           ReWrite(dir_dat);
  536.           Close(dir_dat)
  537.         End; { if }
  538.     Assign(dir_dat,'DIR.DAT');
  539.     Reset(dir_dat);
  540.     entries := 0;
  541.     while not EOF(dir_dat) do
  542.       Begin
  543.         entries := entries + 1;
  544.         ReadLn(dir_dat,sx);
  545.  
  546.         {
  547.          Are we Reading an old DIR3.n file?
  548.         }
  549.  
  550.         if pos('"',sx) > 0
  551.           then
  552.             Begin
  553.               sx := copy(sx,2,15);
  554.               sy := copy(sx,1,8);
  555.               while sy[length(sy)] = ' ' do
  556.                 Begin
  557.                   delete(sy,length(sy),1)
  558.                 End; { While }
  559.               sy := copy(sy + copy(sx,9,4) + '            ',1,12);
  560.               sx := sy + copy(sx,13,3);
  561.               insert('0',sx,13)
  562.             End; { if }
  563.         if copy(sx,13,4) = '0000'
  564.           then
  565.             entries := entries - 1  { don't allow files with '0000' in them }
  566.           else
  567.             files[entries] := sx
  568.       End; { while }
  569.     close(dir_dat)
  570.   End; { Proc Read_Data_From_Disk }
  571.  
  572. Procedure Dump_Data_To_Disk; { Terminal routine...re-execs the program }
  573.   var
  574.     dir_dat : text;
  575.     dir4    : file;
  576.     i       : integer;
  577.  
  578.   Begin
  579.     Cursor(Off);
  580.     TextColor(fore + blink);
  581.     ClrScr;
  582.     GotoXY(20,12);
  583.     Write('Dumping Data to Disk ....');
  584.     Assign(dir_dat,'dir.dat');
  585.     ReWrite(dir_dat);
  586.     for i := 1 to entries do
  587.       Begin
  588.         if files[i][1] <> ' ' then WriteLn(dir_dat,files[i])
  589.       End; { for }
  590.     close(dir_dat);
  591.     Assign(dir4,'DIR4.COM');
  592.     Cursor(On);
  593.     {$I- }
  594.       Execute(dir4);
  595.     {$I+ }
  596.     if IOResult <> 0
  597.       then
  598.         Begin
  599.           ClrScr;
  600.           TextColor(fore);
  601.           GotoXY(1,12);
  602.           WriteLn(^G,'The file "DIR4.COM" was not found.');
  603.           WriteLn('This program MUST be called "DIR4.COM" and be available in your default PATH.');
  604.           WriteLn;
  605.           WriteLn('Program Halted.');
  606.           Halt
  607.         End { if }
  608. End; { Proc Dump_Data_To_Disk }
  609.  
  610. Procedure ShowMenu;
  611.   Begin
  612.     ClrScr;
  613.     Window(19,8,62,22);
  614.     GotoXY(1,1);
  615.     WriteLn('╒═════════════════════════════════════════╕');
  616.     Write  ('│     DIR 4.01 - ');
  617.     Write  (entries:4);
  618.     WriteLn(' Entries on File     │');
  619.     WriteLn('├─────────────────────────────────────────┤');
  620.     Write ('│ [');    TextColor(Fore_hi);
  621.     Write ('F');      TextColor(Fore);
  622.     WriteLn(']ind a File.                          │');
  623.     Write ('│ [');    TextColor(Fore_hi);
  624.     Write ('A');      TextColor(Fore);
  625.     WriteLn(']dd File(s) to the Data Record.       │');
  626.     Write ('│ [');    TextColor(Fore_hi);
  627.     Write ('P');      TextColor(Fore);
  628.     WriteLn(']rint or List the Data Record.        │');
  629.     Write ('│ [');    TextColor(Fore_hi);
  630.     Write ('D');      TextColor(Fore);
  631.     WriteLn(']elete File(s) from the Data Record.  │');
  632.     Write ('│ [');    TextColor(Fore_hi);
  633.     Write ('L');      TextColor(Fore);
  634.     WriteLn(']ist a Disk Directory (Data or Real). │');
  635.     Write ('│ [');    TextColor(Fore_hi);
  636.     Write ('W');      TextColor(Fore);
  637.     WriteLn(']rite a Diskette Label.               │');
  638.     Write ('│ [');    TextColor(Fore_hi);
  639.     Write ('B');      TextColor(Fore);
  640.     WriteLn(']ackup the Data Record File.          │');
  641.     Write ('│ [');    TextColor(Fore_hi);
  642.     Write ('C');      TextColor(Fore);
  643.     WriteLn(']onfigure DIR4.                       │');
  644.     Write ('│ [');    TextColor(Fore_hi);
  645.     Write ('Q');      TextColor(Fore);
  646.     WriteLn(']uit Back to DOS.                     │');
  647.     Write ('╘═════════════════════════════════════════╛');
  648.     Window(1,1,80,25);
  649.   End; { Proc ShowMenu }
  650.  
  651.   Function Yes : boolean;
  652.     var
  653.       c   : char;
  654.       yup : boolean;
  655.  
  656.     Begin
  657.       Repeat
  658.         Repeat Until KeyPressed;
  659.         Read(kbd,c);
  660.         c := UpCase(c)
  661.       Until c in [#13,'Y','N','0','1','-','+'];
  662.       yup := (c in [#13,'Y','+','1']);
  663.       yes := yup;
  664.       if yup
  665.         then
  666.           WriteLn('Yes')
  667.         else
  668.           WriteLn('No')
  669.     End; { Function Yes }
  670.  
  671.   Procedure Fix_Path(var x : files_type);
  672.     Begin
  673.       if x[length(x)] <> '\' then x := x + '\';
  674.       if x[2] <> ':' then insert(':',x,2);
  675.       if pos(x,'*.*') = 0 then x := x + '*.*'
  676.     End; { Proc Fix_Path }
  677.  
  678.   Procedure Add; { a file or files to the data Record }
  679.     Procedure Disk_Read;
  680.       var
  681.         drive : filename_type;
  682.         done,
  683.         f     : boolean;
  684.         i,j,w,z,
  685.         count : integer;
  686.  
  687.       Begin{ Disk_Read }
  688.         disk := '0000';
  689.         done := False;
  690.         Repeat { Until done }
  691.           Repeat { Until Yes and disk <> '0000' }
  692.             x := 0;
  693.             ClrScr;
  694.             GotoXY(20,3);
  695.             val(disk,x,z);
  696.             Write('Disk # to Read (1-9999). Default is ');
  697.             Write(x + 1);
  698.             Write(') ? ');
  699.             z := WhereX;
  700.             ReadLn(sx);
  701.             if sx = ''
  702.               then
  703.                 Begin
  704.                   Str((x + 1),sx);
  705.                   f := True
  706.                 End { if }
  707.               else
  708.                 Begin
  709.                   UpperCase(sx);
  710.                   f := False
  711.                 End; { else }
  712.             Pad_Left(sx,'0',4);
  713.             disk := sx;
  714.             if f
  715.               then
  716.                 Begin
  717.                   GotoXY(z,3);
  718.                   Write(sx)
  719.                 End; { if }
  720.             GotoXY(20,5);
  721.             Write('Enter Drive or Path (Default is B:\) ? ');
  722.             z := WhereX;
  723.             ReadLn(filepath);
  724.             if filepath = ''
  725.               then
  726.                 Begin
  727.                   filepath := 'B:\';
  728.                   f := True
  729.                 End { if }
  730.               else
  731.                 f := False;
  732.             Fix_Path(filepath);
  733.             if f
  734.               then
  735.                 Begin
  736.                   GotoXY(z,5);
  737.                   Write(filepath)
  738.                 End; { if }
  739.             GotoXY(20,7);
  740.             Write('Is Disk #',disk,' on drive ',filepath,' correct ? ');
  741.             if disk = '0000'
  742.               then
  743.                 Begin
  744.                   WriteLn;
  745.                   WriteLn(^G,'"0000" is an illegal Disk value.');
  746.                   WriteLn
  747.                 End { if }
  748.           Until yes and (disk <> '0000');
  749.           Reading := True;
  750.           GotoXY(20,9);
  751.           Write('Deleting all internal references to disk #',disk,'.');
  752.           count := 0;
  753.           for i := 1 to entries do
  754.             Begin
  755.               if disk = copy(files[i],13,4)
  756.                 then
  757.                   Begin
  758.                     files[i][1] := ' ';
  759.                     count := count + 1
  760.                   End { if }
  761.             End; { for }
  762.           GotoXY(20,11);
  763.           if count = 0
  764.             then
  765.               Write('No entries found.')
  766.             else
  767.               Write(count,' entries deleted.');
  768.           Get_File;
  769.           GotoXY(20,13);
  770.           Write('Done. More Disks to Read ? ');
  771.           Done := not Yes
  772.         Until done;
  773.         WriteLn;
  774.         GotoXY(20,15);
  775.         Sort;
  776.         Dump_Data_To_Disk
  777.       End; { sub Proc Disk_Read }
  778.  
  779.     Procedure Manual_Entry;
  780.       var
  781.         done,
  782.         new,
  783.         k    : boolean;
  784.         f,f1 : Str255;
  785.  
  786.       Begin{ Manual_Entry }
  787.         new := False;
  788.         done := False;
  789.         k := False;
  790.         ClrScr;
  791.         GotoXY(1,12);
  792.         Repeat { Until Done }
  793.           Repeat { Until done or k, where k = Yes }
  794.             Write('Enter File ("*" to Quit) ? ');
  795.             ReadLn(f);
  796.             if f = '*'
  797.               then
  798.                 Begin
  799.                   done := True;
  800.                   k := False
  801.                 End { if }
  802.               else
  803.                 Begin
  804.                   UpperCase(f);
  805.                   WriteLn;
  806.                   Write('Enter Disk # (1-9999) ? ');
  807.                   ReadLn(f1);
  808.                   Pad_Left(f1,'0',4);
  809.                   UpperCase(f1);
  810.                   WriteLn;
  811.                   Write('Is ',f,' on Disk #',f1,' Correct ? ');
  812.                   k := yes;
  813.                   if f1 = '0000'
  814.                     then
  815.                       Begin
  816.                         k := False;
  817.                         WriteLn(^G,'"0000" is an illegal Disk label!');
  818.                       End { if }
  819.                 End; { else }
  820.             WriteLn
  821.           Until done or k; { k = Yes }
  822.           if k
  823.             then
  824.               Begin
  825.                 new := True;
  826.                 entries := entries + 1;
  827.                 Pad_Right(f,' ',12);
  828.                 files[entries] := f + f1
  829.               End { if k }
  830.         Until done;
  831.         if new
  832.           then
  833.             Begin
  834.               Sort;
  835.               Dump_Data_To_Disk
  836.             End { if }
  837.       End; { sub Proc Manual_Entry }
  838.  
  839.     var
  840.       chc : char;
  841.  
  842.     Begin { Add }
  843.       ClrScr;
  844.       GotoXY(20,12);
  845.       Write('Manually ');
  846.       TextColor(fore_hi + blink);
  847.       Write('A');
  848.       TextColor(fore);
  849.       Write('dd file(s), Read a ');
  850.       TextColor(fore_hi + blink);
  851.       Write('D');
  852.       TextColor(fore);
  853.       Write('isk, or ');
  854.       TextColor(fore_hi + blink);
  855.       Write('Q');
  856.       TextColor(fore);
  857.       Write('uit ? ');
  858.       Repeat
  859.         Repeat Until Keypressed;
  860.         Read(kbd,chc);
  861.         chc := UpCase(chc)
  862.       Until pos(chc,'ADQ*') > 0;
  863.       Case chc of
  864.         'A' : manual_entry;
  865.         'D' : disk_Read
  866.       End { Case chc }
  867.     End; { Proc Add }
  868.  
  869. Procedure Configure;
  870.   var
  871.     chc,c :  char;
  872.     done  :  boolean;
  873.     i     :  integer;
  874.  
  875.   Begin
  876.     done := False;
  877.     Repeat { Until done }
  878.       ClrScr;
  879.       Cursor(Off);
  880.       Window(19,1,62,13);
  881.       GotoXY(1,1);
  882.       WriteLn('╒═════════════════════════════════════════╕');
  883.       WriteLn('│      DIR 4.01 - Configuration Menu      │');
  884.       WriteLn('├─────────────────────────────────────────┤');
  885.       Write ('│ Change [');    TextColor(Fore_hi);
  886.       Write ('F');      TextColor(Fore);
  887.       WriteLn(']oreground Color.              │');
  888.       Write ('│ Change [');    TextColor(Fore_hi);
  889.       Write ('H');      TextColor(Fore);
  890.       WriteLn(']ighlight Color.               │');
  891.       Write ('│ Change [');    TextColor(Fore_hi);
  892.       Write ('B');      TextColor(Fore);
  893.       WriteLn(']ackground Color.              │');
  894.       Write ('│ Change Bo[');    TextColor(Fore_hi);
  895.       Write ('R');      TextColor(Fore);
  896.       WriteLn(']der Color.                  │');
  897.       Write ('│ Enter [');       TextColor(Fore_hi);
  898.       Write ('P');      TextColor(Fore);
  899.       WriteLn(']rinter 16 cpi Control String:  │');
  900.       Write('│    Current String = ');
  901.       TextColor(fore_hi);
  902.       Write(copy(cpi16 + '                    ',1,20));
  903.       TextColor(fore);
  904.       WriteLn('│');
  905.       Write ('│ [');    TextColor(Fore_hi);
  906.       Write ('S');      TextColor(Fore);
  907.       WriteLn(']ave Configuration.                   │');
  908.       Write ('│ [');    TextColor(Fore_hi);
  909.       Write ('Q');      TextColor(Fore);
  910.       WriteLn(']uit Back to the Main Menu.           │');
  911.       Write ('╘═════════════════════════════════════════╛');
  912.       Repeat { Until valid choice selected }
  913.         Repeat Until KeyPressed;
  914.         Read(kbd,chc);
  915.         chc := UpCase(chc)
  916.       Until pos(chc,'FHBRSPQ*') > 0;
  917.       Window(20,14,80,24);
  918.       GotoXY(1,1);
  919.       ClrScr;
  920.       Cursor(On);
  921.       Case chc of
  922.         'F' : Begin
  923.                 for i:=0 to 15 do
  924.                   Begin
  925.                     TextColor(i);
  926.                     Write('███')
  927.                   End; { for }
  928.                 TextColor(fore);
  929.                 WriteLn;
  930.                 WriteLn(' 0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F');
  931.                 Write(' Select New Foreground Color (0-F) ');
  932.                 Repeat
  933.                   Repeat Until KeyPressed;
  934.                   Read(kbd,c);
  935.                   c := UpCase(c);
  936.                   i := pos(c,'0123456789ABCDEF')
  937.                 Until i > 0;
  938.                 fore := i - 1;
  939.                 TextColor(fore)
  940.               End; { Case 'F' }
  941.         'H' : Begin
  942.                 for i := 0 to 15 do
  943.                   Begin
  944.                     TextColor(i);
  945.                     Write('███')
  946.                   End; { for }
  947.                 TextColor(fore);
  948.                 WriteLn;
  949.                 WriteLn(' 0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F');
  950.                 Write(' Select New Highlight Color (0-F) ');
  951.                 Repeat
  952.                   Repeat Until KeyPressed;
  953.                   Read(kbd,c);
  954.                   c := UpCase(c);
  955.                   i := pos(c,'0123456789ABCDEF')
  956.                 Until i > 0;
  957.                 fore_hi := i - 1
  958.               End; { Case 'H' }
  959.         'B' : Begin
  960.                 for i := 0 to 7 do
  961.                   Begin
  962.                     TextColor(i);
  963.                     Write('███')
  964.                   End; { for }
  965.                 TextColor(fore);
  966.                 WriteLn;
  967.                 WriteLn(' 0  1  2  3  4  5  6  7');
  968.                 Write(' Select New Background Color (0-7) ');
  969.                 Repeat
  970.                   Repeat Until KeyPressed;
  971.                   Read(kbd,c);
  972.                   c := UpCase(c);
  973.                   i := pos(c,'01234567')
  974.                 Until i > 0;
  975.                 back := i - 1;
  976.                 TextBackground(back);
  977.                 window(1,1,80,25);
  978.                 color(fore,back,bord)
  979.               End;  { Case 'B' }
  980.         'R' : Begin
  981.                 for i := 0 to 7 do
  982.                   Begin
  983.                     TextColor(i);
  984.                     Write('███')
  985.                   End; { for }
  986.                 TextColor(fore);
  987.                 WriteLn;
  988.                 WriteLn(' 0  1  2  3  4  5  6  7');
  989.                 Write(' Select New Border Color (0-7) ');
  990.                 Repeat
  991.                   Repeat Until KeyPressed;
  992.                   Read(kbd,c);
  993.                   c := UpCase(c);
  994.                   i := pos(c,'01234567')
  995.                 Until i > 0;
  996.                 bord := i - 1;
  997.                 port[$03d9] := bord
  998.               End;  { Case 'R' }
  999.         'S' : Begin
  1000.                 Cursor(Off);
  1001.                 Assign(ft,'dir4.cfg');
  1002.                 ReWrite(ft);
  1003.                 WriteLn(ft,fore);
  1004.                 WriteLn(ft,back);
  1005.                 WriteLn(ft,bord);
  1006.                 WriteLn(ft,fore_hi);
  1007.                 WriteLn(ft,cpi16);
  1008.                 close(ft);
  1009.                 Cursor(On)
  1010.               End;  { Case 'S' }
  1011.         'P' : Begin
  1012.                 WriteLn('Enter the command string that places your printer into');
  1013.                 WriteLn('condensed (16 cpi) mode. Use "{" for the Esc character');
  1014.                 Write('and "^" for Ctrl. String ? ');
  1015.                 ReadLn(cpi16);
  1016.                 if pos('{',cpi16)>0 then cpi16[pos('{',cpi16)] := #27;
  1017.                 i := pos('^',cpi16);
  1018.                 if i > 0
  1019.                   then
  1020.                     Begin
  1021.                       cpi16[i + 1] := UpCase(cpi16[i + 1]);
  1022.                       if (ord(cpi16[i + 1]) -64 >= 0) and
  1023.                          (ord(cpi16[i + 1]) -64 <= 31)
  1024.                         then
  1025.                           Begin
  1026.                             cpi16[i + 1] := chr(ord(cpi16[i + 1]) - 64);
  1027.                             delete(cpi16,i,1)
  1028.                           End { if (ord ... }
  1029.                     End { if i ... }
  1030.               End       { Case 'P' }
  1031.          else           { Cases Q and * }
  1032.            done := True
  1033.       End               { Case of chc }
  1034.     Until Done;
  1035.     window(1,1,80,25)
  1036.   End;                  { Proc Configure }
  1037.  
  1038. Procedure Backup;
  1039.   var
  1040.     dir_dat : text;
  1041.     ft      : Str255;
  1042.     i       : integer;
  1043.     no_err  : boolean;
  1044.  
  1045.   Begin
  1046.     ClrScr;
  1047.     Cursor(Off);
  1048.     GotoXY(1,12);
  1049.     Repeat { until no_err }
  1050.       Write('Backup "DIR.DAT" onto which drive ("*" to quit) ? ');
  1051.       ReadLn(ft);
  1052.       if ft = '*' then Exit;
  1053.       UpperCase(ft);
  1054.       if copy(ft,length(ft),1) <> ':' then ft := ft + ':';
  1055.       Assign(dir_dat,ft + 'dir.dat');
  1056.       {$I- }
  1057.         ReWrite(dir_dat);
  1058.       {$I+ }
  1059.       no_err := (IOResult = 0);
  1060.       if not no_err
  1061.         then
  1062.           Begin
  1063.             WriteLn;
  1064.             WriteLn(^G,'An I/O error occurred. Drive "',ft,'" is probably incorrect. Please try again.');
  1065.             WriteLn
  1066.           End { if }
  1067.     Until no_err;
  1068.     ClrScr;
  1069.     GotoXY(20,12);
  1070.     TextColor(fore + blink);
  1071.     Write('Backing "DIR.DAT" to drive ',ft);
  1072.     for i := 1 to entries do
  1073.       Begin
  1074.         if files[i][1] <> ' ' then WriteLn(dir_dat,files[i])
  1075.       End; { for }
  1076.     close(dir_dat);
  1077.     TextColor(fore)
  1078.   End; { Proc BackUp }
  1079.  
  1080. Procedure Zap; { Deletes one or more files or a complete diskette }
  1081.   var
  1082.     i,j,k  : integer;
  1083.     c      : char;
  1084.     sx     : Str255;
  1085.     mark,
  1086.     done,
  1087.     zapped : boolean;
  1088.  
  1089.   Begin
  1090.     zapped := False;
  1091.     ClrScr;
  1092.     GotoXY(1,12);
  1093.     Write('Delete a ');
  1094.     TextColor(fore_hi + blink);
  1095.     Write('F');
  1096.     TextColor(fore);
  1097.     Write('ile, a ');
  1098.     TextColor (fore_hi + blink);
  1099.     Write('D');
  1100.     TextColor(fore);
  1101.     Write('isk, or ');
  1102.     TextColor (fore_hi + blink);
  1103.     Write('Q');
  1104.     TextColor(fore);
  1105.     Write('uit back to the Main Menu ? ');
  1106.     Repeat
  1107.       Repeat Until KeyPressed;
  1108.       Read(kbd,c);
  1109.       c := UpCase(c)
  1110.     Until pos(c,'FDQ*') > 0;
  1111.     Case c of
  1112.       'F' : Begin
  1113.               ClrScr;
  1114.               GotoXY(1,12);
  1115.               done := False;
  1116.               Repeat { Until done }
  1117.                 mark := False;
  1118.                 Write('File to delete ("*" to quit) ? ');
  1119.                 ReadLn(sx);
  1120.                 UpperCase(sx);
  1121.                 if sx = '*' then done := True;
  1122.                 if not done
  1123.                   then
  1124.                     for i := 1 to entries do
  1125.                       Begin
  1126.                         if pos(sx,files[i]) > 0
  1127.                           then
  1128.                             Begin
  1129.                               files[i][1] := ' ';
  1130.                               mark := True;
  1131.                               zapped := True
  1132.                             End { if }
  1133.                       End; { for i }
  1134.                 if not mark
  1135.                   then
  1136.                     Begin
  1137.                       WriteLn;
  1138.                       WriteLn('File "',sx,'" wasn',#39,'t found.');
  1139.                       WriteLn
  1140.                     End { if not mark }
  1141.                   else
  1142.                     WriteLn
  1143.               Until done
  1144.             End; { Case F }
  1145.       'D' : Begin
  1146.               j := 0;
  1147.               done := False;
  1148.               ClrScr;
  1149.               GotoXY(1,12);
  1150.               done := False;
  1151.               Repeat { Until done }
  1152.                 Write('Enter Disk # (1-9999) to Delete ("*" to Quit) ? ');
  1153.                 ReadLn(sx);
  1154.                 UpperCase(sx);
  1155.                 if sx = '*'
  1156.                   then
  1157.                     done := True
  1158.                   else
  1159.                     Begin
  1160.                       Pad_Left(sx,'0',4) ;
  1161.                       mark := False;
  1162.                       j := 0;
  1163.                       for i := 1 to entries do
  1164.                         Begin
  1165.                           if sx = copy(files[i],13,4)
  1166.                           then
  1167.                             Begin
  1168.                               mark := True;
  1169.                               zapped := True;
  1170.                               files[i] := ' ';
  1171.                               j := j + 1
  1172.                             End { if }
  1173.                         End; { for i }
  1174.                       if mark
  1175.                         then
  1176.                           Begin
  1177.                             WriteLn;
  1178.                             WriteLn('Done. ',j,' files were deleted.')
  1179.                           End { if }
  1180.                         else
  1181.                           Begin
  1182.                             WriteLn;
  1183.                             WriteLn('Disk #',sx,' wasn',#39,'t found.')
  1184.                           End; { else }
  1185.                       WriteLn
  1186.                   End { else not done }
  1187.               Until done
  1188.             End { Case D }
  1189.     End; { Case of c }
  1190.     if zapped then Dump_Data_To_Disk
  1191.   End; { Proc Zap }
  1192.  
  1193. Procedure Strip_Z(var x : Str255); { Strip leading zeros }
  1194.   Begin
  1195.     while x[1] = '0' do delete(x,1,1)
  1196.   End; { Proc Strip_Z }
  1197.  
  1198. Procedure Find;
  1199.   Procedure Strip_S(var x : Str255); { Strips trailing spaces from a string }
  1200.     Begin
  1201.       while x[length(x)] = ' ' do delete(x,length(x),1)
  1202.     End; { Sub Proc Strip_S }
  1203.  
  1204.   var
  1205.     i,j              : integer;
  1206.     st,stmp,s        : Str255;
  1207.     done,found,mark  : boolean;
  1208.  
  1209.   Begin
  1210.     ClrScr;
  1211.     GotoXY(1,10);
  1212.     done := False;
  1213.     Repeat { Until done }
  1214.       Write('Enter File (or Partial) to Find ("*" to Quit) ? ');
  1215.       ReadLn(st);
  1216.       WriteLn;
  1217.       if st = '*'
  1218.         then
  1219.           done := True
  1220.         else
  1221.           Begin
  1222.             found := False;
  1223.             Repeat { Until found }
  1224.               UpperCase(st);
  1225.               mark := False;
  1226.               i := 0;
  1227.               Repeat { Until i >= entries OR Found }
  1228.                 i := i + 1;
  1229.                 if pos(st,copy(files[i],1,12)) > 0
  1230.                   then
  1231.                     Begin
  1232.                       mark := True;
  1233.                       stmp := copy(files[i],1,12);
  1234.                       Strip_S(stmp);
  1235.                       WriteLn(stmp,' may be found on Disk(s):');
  1236.                       s := copy(files[i],13,4);
  1237.                       Strip_Z(s);
  1238.                       i := i + 1;
  1239.                       Write(s,', ');
  1240.                       for j := i to entries do
  1241.                         Begin
  1242.                           if pos(stmp,files[j]) > 0
  1243.                             then
  1244.                               Begin
  1245.                                 s := copy(files[j],13,4);
  1246.                                 Strip_Z(s);
  1247.                                 Write(s,', ');
  1248.                                 i := i + 1
  1249.                               End { if }
  1250.                         End; { for j }
  1251.                       WriteLn;
  1252.                       WriteLn;
  1253.                       Write('Is this the file you wanted ? ');
  1254.                       Found := Yes;
  1255.                       WriteLn
  1256.                     End { if }
  1257.               Until (i >= entries) or Found;
  1258.               if not mark
  1259.                 then
  1260.                   Begin
  1261.                     WriteLn;
  1262.                     WriteLn('"',st,'" wasn',#39,'t found.');
  1263.                     WriteLn;
  1264.                     found := True
  1265.                   End { if }
  1266.                 else
  1267.                   Begin
  1268.                     if i >= entries
  1269.                       then
  1270.                         Begin
  1271.                           found := True;
  1272.                           WriteLn('No further incidences of "',st,'" were found.');
  1273.                           WriteLn
  1274.                         End { if }
  1275.                       else
  1276.                         WriteLn
  1277.                   End { else }
  1278.             Until Found
  1279.           End { else }
  1280.     Until done
  1281.   End; { Proc Find }
  1282.  
  1283. Procedure Print_List;
  1284.   Procedure Print_Prt;
  1285.     var
  1286.       i,page,pages   : integer;
  1287.       linestr,
  1288.       headerstr      : string[126];
  1289.       s,s1,ds,dys,ts : Str255;
  1290.  
  1291.     Begin{ Print_Prt - Prints 7 columns of 50 entries each }
  1292.       WriteLn;
  1293.       WriteLn;
  1294.       WriteLn('Position your printer to about ',#171,'" below the top perforation and press any');
  1295.       Write('key to start the printout ("*" to quit) ? ');
  1296.       Repeat Until Keypressed;
  1297.       Read(Kbd,ch);
  1298.       if ch = '*' then Exit;
  1299.       WriteLn;
  1300.       WriteLn;
  1301.       Write('Printing Data Record. Press any key to abort ....');
  1302.       Write(Lst,cpi16);
  1303.       pages := entries div 350 + 1;
  1304.       linestr :='';
  1305.       for i := 1 to 124 do linestr := linestr + '-';
  1306.       headerstr := '';
  1307.       for i := 1 to 7 do headerstr := headerstr + 'File        Disk  ';
  1308.       for page := 1 to pages do
  1309.         Begin
  1310.           WriteLn(Lst);
  1311.           TimDat(ts,ds,dys);
  1312.           WriteLn(Lst,'      DIR.DAT Listing as of ',dys,', ',ds,' @ ',ts,'.');
  1313.           WriteLn(Lst,'      Page ',page,' of ',pages,' Pages.');
  1314.           WriteLn(Lst,'      ',headerstr);
  1315.           WriteLn(Lst,'      ',linestr);
  1316.           for x:= (page - 1) * 350 to (page - 1) * 350 + 49 do
  1317.             Begin
  1318.               Write(Lst,'      ');
  1319.               y := 1;
  1320.               While y <= 350 do
  1321.                 Begin
  1322.                   if KeyPressed
  1323.                     then
  1324.                       Exit
  1325.                     else
  1326.                       Begin
  1327.                         if (x + y) <= entries
  1328.                           then
  1329.                             Begin
  1330.                               if Sort_Flag
  1331.                                 then
  1332.                                   Begin
  1333.                                     s := copy(files[x + y],1,4);
  1334.                                     Strip_Z(s);
  1335.                                     s1 := copy(files[x + y],5,12);
  1336.                                     s1 := copy(s1 + '    ',1,12);
  1337.                                     Write(Lst,s1,s:4,'  ')
  1338.                                   End { if Sort_Flag }
  1339.                                 else
  1340.                                   Begin
  1341.                                     s := copy(files[x + y],13,4);
  1342.                                     Strip_Z(s);
  1343.                                     s1 := copy(files[x + y],1,12) + '    ';
  1344.                                     s1 := copy(s1,1,12);
  1345.                                     Write(Lst,s1,s:4,'  ')
  1346.                                   End { else if Sort_Flag }
  1347.                             End { if }
  1348.                       End; { else if KeyPressed }
  1349.                   y := y + 50
  1350.                 End; { while y }
  1351.               WriteLn(Lst)
  1352.             End; { for x }
  1353.           WriteLn(Lst,'      ',linestr);
  1354.           for i := 1 to 10 do WriteLn(Lst)
  1355.         End; { for page }
  1356.       if KeyPressed then Read(Kbd,ch)
  1357.     End; { Sub Proc Print_Prt }
  1358.  
  1359.   Procedure Print_Crt;
  1360.     var
  1361.       i    : integer;
  1362.       s    : Str255;
  1363.  
  1364.     Begin{ Proc Print_Crt }
  1365.       ClrScr;
  1366.       GotoXY(1,1);
  1367.       i := 1;
  1368.       Repeat { Until c = * OR i > entries }
  1369.         if Sort_Flag
  1370.           then
  1371.             s := copy(files[i],1,4)
  1372.           else
  1373.             s := copy(files[i],13,4);
  1374.         Strip_Z(s);
  1375.         s := copy('    ' + s,length(s) + 1,4);
  1376.         if Sort_Flag
  1377.           then
  1378.             Write(s,' ',copy(files[i],5,12),'  ')
  1379.           else
  1380.             Write(s,' ',copy(files[i],1,12),'  ');
  1381.         Check_Pos;
  1382.         i := i + 1;
  1383.       Until (choice = '*') or (i > entries);
  1384.       choice := ' ';
  1385.       if i > entries then AtEnd;
  1386.       WriteLn
  1387.     End; { Sub Proc Print_Crt }
  1388.  
  1389.   var
  1390.     c : char;
  1391.  
  1392.   Begin{ Print_List Main }
  1393.     ClrScr;
  1394.     GotoXY(1,12);
  1395.     Write('Do you want the Data Record Sorted by Disk Number ? ');
  1396.     if Yes
  1397.       then
  1398.         Begin
  1399.           WriteLn;
  1400.           Sort_By_Num
  1401.         End; { if }
  1402.     WriteLn;
  1403.     Write('Dump the Data Record to the ');
  1404.     TextColor(fore_hi + blink);
  1405.     Write('C');
  1406.     TextColor(Fore);
  1407.     Write('RT, the ');
  1408.     TextColor(fore_hi + blink);
  1409.     Write('P');
  1410.     TextColor(fore);
  1411.     Write('rinter, or ');
  1412.     TextColor(fore_hi + blink);
  1413.     Write('Q');
  1414.     TextColor(fore);
  1415.     Write('uit ? ');
  1416.     Repeat
  1417.       Repeat Until KeyPressed;
  1418.       Read(kbd,c);
  1419.       c := UpCase(c)
  1420.     Until pos(c,'CPQ*') > 0;
  1421.     Case c of
  1422.       'C' : Print_Crt;
  1423.       'P' : Print_Prt
  1424.     End { Case of c }
  1425.   End; { Proc Print_List }
  1426.  
  1427. Procedure List_Records;
  1428.   Procedure List_Actual;
  1429.     Var target : Str255;
  1430.  
  1431.     Begin
  1432.       ClrScr;
  1433.       GotoXY(1,12);
  1434.       Write('Enter drive or path to be listed ("*" to quit) ? ');
  1435.       ReadLn(target);
  1436.       ClrScr;
  1437.       GotoXY(1,1);
  1438.       if target <> '*'
  1439.         then
  1440.           Begin
  1441.             Fix_Path(target);
  1442.             filepath := target;
  1443.             Reading := False;
  1444.             ClrScr;
  1445.             Get_File
  1446.           End { if target <> * }
  1447.     End; { Sub Proc List_Actual }
  1448.  
  1449.   Procedure List_Data;
  1450.     var i    : integer;
  1451.     target,s : Str255;
  1452.  
  1453.     Begin
  1454.       ClrScr;
  1455.       GotoXY(1,12);
  1456.       Write('Enter disk # (1-9999) to be listed ("*" to quit) ? ');
  1457.       ReadLn(target);
  1458.       UpperCase(target);
  1459.       ClrScr;
  1460.       GotoXY(1,1);
  1461.       if target <> '*'
  1462.         then
  1463.           Begin
  1464.             i := 1;
  1465.             Pad_Left(target,'0',4);
  1466.             Repeat { until i > entries or choice = * }
  1467.               if target = copy(files[i],13,4)
  1468.                 then
  1469.                   Begin
  1470.                     s := copy(files[i],13,4);
  1471.                     Strip_Z(s);
  1472.                     Pad_Left(s,' ',4);
  1473.                     Write(s,' ',copy(files[i],1,12),'  ');
  1474.                     Check_Pos
  1475.                   End; { if target = }
  1476.               i := i + 1
  1477.             Until (i > entries) or (choice = '*');
  1478.             choice := ' ';
  1479.             if i > entries then AtEnd
  1480.           End { if target <> '*' }
  1481.     End; { Sub Proc List_Data }
  1482.  
  1483.   Begin{ Proc List_Records Main }
  1484.     ClrScr;
  1485.     GotoXY(1,12);
  1486.     Write('List an ');
  1487.     TextColor(fore_hi + blink);
  1488.     Write('A');
  1489.     TextColor(Fore);
  1490.     Write('ctual Disk Directory, the ');
  1491.     TextColor(fore_hi + blink);
  1492.     Write('D');
  1493.     TextColor(fore);
  1494.     Write('ata Record, or ');
  1495.     TextColor(fore_hi + blink);
  1496.     Write('Q');
  1497.     TextColor(fore);
  1498.     Write('uit ? ');
  1499.     Repeat
  1500.       Repeat Until KeyPressed;
  1501.       Read(kbd,ch);
  1502.       ch := UpCase(ch)
  1503.     Until pos(ch,'ADQ*') > 0;
  1504.     Case ch of
  1505.       'A' : List_Actual;
  1506.       'D' : List_Data
  1507.     End { Case of ch }
  1508.   End; { Proc List_Records }
  1509.  
  1510. Procedure Write_Label;
  1511.   var
  1512.     i,count    : integer;
  1513.     horiz_line,
  1514.     tmp_line,
  1515.     t_line     : string[74];
  1516.     target,
  1517.     tm,dt,dy   : Str255;
  1518.  
  1519.   Begin
  1520.     horiz_line := '+';
  1521.     for i := 1 to 72 do horiz_line := horiz_line + '-';
  1522.     horiz_line := horiz_line + '+';
  1523.     t_line := '|' + copy(horiz_line,2,72) + '|';
  1524.     ClrScr;
  1525.     GotoXY(1,12);
  1526.     Write('Write a Label for which disk (1-9999) - ("*" to quit) ? ');
  1527.     ReadLn(target);
  1528.     UpperCase(target);
  1529.     ClrScr;
  1530.     GotoXY(1,12);
  1531.     Write('Printing Label .....');
  1532.     if target <> '*'
  1533.       then
  1534.         Begin
  1535.           i := 1;
  1536.           Pad_Left(target,'0',4);
  1537.           TimDat(tm,dt,dy);
  1538.           WriteLn(Lst,cpi16,horiz_line);
  1539.           WriteLn(Lst,'| Disk #',target,'. ',dt,'                                                 |');
  1540.           WriteLn(Lst,t_line);
  1541.           count := 2;
  1542.           tmp_line := '| ';
  1543.           Repeat { until i > entries }
  1544.             if target = copy(files[i],13,4)
  1545.               then
  1546.                 Begin
  1547.                   tmp_line := tmp_line + copy(files[i],1,12) + '  ';
  1548.                   if length(tmp_line) > 70
  1549.                     then
  1550.                       Begin
  1551.                         tmp_line := tmp_line + ' |';
  1552.                         WriteLn(Lst,tmp_line);
  1553.                         tmp_line := '| ';
  1554.                         count :=  count + 1
  1555.                       End { if length(tmp_line) }
  1556.                 End; { if target }
  1557.             i := i + 1
  1558.           Until i > entries;
  1559.           while count < 26 do
  1560.             Begin
  1561.               while (length(tmp_line) < 72) do
  1562.                 Begin
  1563.                   tmp_line := tmp_line + ' ';
  1564.                 End; { while length }
  1565.               tmp_line := tmp_line + ' |';
  1566.               WriteLn(Lst,tmp_line);
  1567.               count := count + 1;
  1568.               tmp_line := '| '
  1569.             End; { while count }
  1570.           WriteLn(Lst,horiz_line);
  1571.           for i := 1 to 5 do WriteLn(Lst)
  1572.         End { if target }
  1573.   End; { Proc Write_Label }
  1574.  
  1575. Procedure Do_It; { Essentially the main loop }
  1576.   Begin
  1577.     Cursor(Off);
  1578.     Init;
  1579.     Read_Data_From_Disk;
  1580.     Repeat { Until Choice = Q or * }
  1581.       if Sort_Flag then Sort_By_Num;
  1582.       ClrScr;
  1583.       Cursor(Off);
  1584.       ShowMenu;
  1585.       Repeat { Until a valid choice is selected }
  1586.         Repeat Until KeyPressed;
  1587.         Read(kbd,choice);
  1588.         choice := UpCase(choice)
  1589.       Until pos(choice,'ABCDFLPQW*') > 0;
  1590.       Cursor(On);
  1591.       Case choice of
  1592.         'A' : Add;
  1593.         'B' : Backup;
  1594.         'C' : Configure;
  1595.         'D' : Zap;
  1596.         'F' : Find;
  1597.         'L' : List_Records;
  1598.         'P' : Print_List;
  1599.         'W' : Write_Label
  1600.       End { Case of Choice }
  1601.     Until (choice = 'Q') or (choice = '*');
  1602.     Set_Cursor(5,6)
  1603.   End; { Proc Do_It }
  1604.  
  1605. Begin       {     ╒═════════════════════════════════════════╕     }
  1606.   Do_It     {     │                  Main                   │     }
  1607. End.        {     ╘═════════════════════════════════════════╛     }
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.