home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0102.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-20  |  4.1 KB  |  147 lines

  1. Program PickEdit;
  2.  
  3. Uses
  4.   Crt;
  5.  
  6. Type
  7.   NameRecord  = Record
  8.                   CursorPos : Word;
  9.                   PickName  : Array [1..80] of Char;
  10.                 End;
  11.   NameArray   = Record
  12.                   num  : Word;
  13.                   size : Word;
  14.                   ar   : Array [1..9] of NameRecord
  15.                 End;
  16.   FileOrder   = Record
  17.                   num  : Word;
  18.                   size : Word;
  19.                   ar   :  Array [1..9] of Word;
  20.                 End;
  21.   EditInfo    = Record
  22.                   ScreenOffset : Byte;
  23.                   UpLeftOffset : Word;
  24.                   CursorColumn : Word;
  25.                   PlaceMarkers : Array [1..4] of Word;
  26.                   StartOfBlock : Word;
  27.                   EndOfBlock   : Word;
  28.                 End;
  29.   EditArray   = Record
  30.                   num  : Word;
  31.                   size : Word;
  32.                   ar   : Array [1..9] of EditInfo;
  33.                 End;
  34.   BlockInfo   = Record
  35.                   StatusOfBlock : Word;
  36.                   DateTimeStamp : LongInt;
  37.                 End;
  38.   BlockArray = Record
  39.                  num  : Word;
  40.                  size : Word;
  41.                  ar   : Array [1..9] of BlockInfo;
  42.                End;
  43.   PickItems  = Record
  44.                  one    : NameArray;
  45.                  two    : FileOrder;
  46.                  three  : EditArray;
  47.                  four   : BlockArray;
  48.                End;
  49.  
  50. Var
  51.   pf : File;
  52.   pl : PickItems;
  53.   nm : Byte;
  54.  
  55. Function GetChoice : Byte;
  56. { This function will get the correct key press. It handles  }
  57. { 0..9 and Q to quit and ESC to abort. A byte value for the }
  58. { key is returned.                                          }
  59. Var
  60.   ch : char;
  61. Begin
  62.   Repeat
  63.     ch := Upcase ( ReadKey );
  64.   Until ( ch in ['1'..'9','Q',#27] ); { Check if key is ok }
  65.   if ( ch = 'Q' ) Then                { If QUIT key is pressed }
  66.     GetChoice := 0
  67.   else
  68.   if ( ch = #27 ) Then                { If ABORT key is pressed }
  69.     GetChoice := $FF
  70.   else
  71.     GetChoice := Ord ( ch ) - Ord ( '1' ) + 1;
  72. End;
  73.  
  74. Procedure ShowPick;
  75. { This procedure will display the names of the files in the pick }
  76. { list to the screen based on their order in the list.           }
  77. Var
  78.   loop,
  79.   entry : Word;
  80.   s : String;
  81. Begin
  82.   ClrScr;
  83.   For loop := 1 To 9 Do
  84.   Begin
  85.     entry := pl.Two.Ar[loop] + 1;
  86.     Write ( loop, '. [ ', entry, '[ ' );
  87.     s := pl.One.Ar[entry].PickName;
  88.     s[0] := chr ( Pos ( #0, s ) - 1 );
  89.     WriteLn ( s );
  90.   End;
  91. End;
  92.  
  93. Procedure ReadPickFile;
  94. { This file opens the TURBO.PCK file and reads the pertinent }
  95. { information.                                               }
  96. Begin
  97.   Assign ( pf, 'TURBO.PCK' );
  98.   Reset ( pf, 1 );
  99.   Seek ( pf, 39 );            { Seek to start of information }
  100.   BlockRead ( pf, pl, SizeOf ( pl ) );
  101. End;
  102.  
  103. Procedure DeletePick ( b : Byte );
  104. Var
  105.   i,
  106.   tmp : Word;
  107. Begin
  108.   tmp := pl.Two.Ar[b];         { Store array list info }
  109.   for i := b + 1 to 9 do       { Delete item from array list }
  110.     pl.Two.Ar[i-1] := pl.Two.Ar[i];
  111.   pl.Two.Ar[9] := 9;
  112.   b := tmp + 1;
  113.   For i := 1 to 9 do           { Decrement elements in array list }
  114.     If ( pl.Two.Ar[i] > tmp ) Then
  115.       Dec ( pl.Two.Ar[i] );
  116.   For i := b + 1 To 9 Do       { Reorganize the list to fill the }
  117.   Begin                        { empty space in.                 }
  118.     pl.One.Ar[i-1]   := pl.One.Ar[i];
  119.     pl.Three.Ar[i-1] := pl.Three.Ar[i];
  120.     pl.Four.Ar[i-1]  := pl.Four.Ar[i];
  121.     FillChar ( pl.One.Ar[i], SizeOf ( pl.One.Ar[i] ), #0 );
  122.     FillChar ( pl.Three.Ar[i], SizeOf ( pl.Three.Ar[i] ), #0 );
  123.     FillChar ( pl.Four.Ar[i], SizeOf ( pl.Four.Ar[i] ), #0 );
  124.   End;
  125. End;
  126.  
  127. Procedure WritePickFile;
  128. { This procedure will update the TURBO.PCK file on the disk. }
  129. Begin
  130.   Seek ( pf, 39 );
  131.   BlockWrite ( pf, pl, SizeOf ( pl ) );
  132. End;
  133.  
  134. Begin
  135.   ReadPickFile;
  136.   Repeat
  137.     ShowPick;
  138.     Write ( 'Enter the number of file to delete, "Q" to quit or ESC to abort.' );
  139.     nm := GetChoice;
  140.     If ( nm > 0 ) AND ( nm < $FF ) Then
  141.       DeletePick ( nm );
  142.   Until ( nm = 0 ) OR ( nm = $FF );
  143.   If ( nm < $FF ) Then
  144.     WritePickFile;
  145.   Close ( pf );
  146. End.
  147.