home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / MISCTI10.ZIP / TI245.ASC < prev    next >
Encoding:
Text File  |  1988-04-18  |  3.5 KB  |  92 lines

  1. PRODUCT : TURBO EDITOR TOOLBOX     NUMBER : 245
  2. VERSION : 1.00A
  3.      OS : PC-DOS
  4.    DATE : March 13, 1986
  5.  
  6.   TITLE  :  FILE TRUNCATION UPDATE FROM VERSION 1.00A TO 1.00B
  7.  
  8. The  changes   to  the  Turbo Editor Toolbox  described  in  this 
  9. handout  prevent the truncation of files when they are read  from 
  10. disk.  The Reset procedure in Turbo Pascal 3.0 provides a  second 
  11. optional  parameter that defines the size of a block  when  using 
  12. untyped files.  By setting the block size to 1 byte, you are able 
  13. to  determine   the  exact number of  characters to  be  read  by 
  14. calling   Turbo Pascal's function,  LongFileSize.   You can  then  
  15. perform blockreads of the exact amount of bytes and avoid reading  
  16. too  many  or too few bytes  from disk.   Please see  the READ.ME 
  17. file  in  your  manual  or on  your  Turbo  Pascal  diskette  for 
  18. additional information about the optional Reset parameter.
  19.  
  20.   The routine to be modified is called:
  21.  
  22.      procedure EditReatxtfil (Fn : Varstring);
  23.  
  24.   This routine exists in two files:
  25.  
  26.     KCMD.MS, on the MicroStar Source diskette
  27.     USER.ED,  on  the  .COM Files,  Turbo Editor  Toolbox  SOURCE     
  28. diskette
  29.  
  30. The modified  lines  of code are  listed in  the routine below
  31. with a comment at the  end of the line: { Ver. 1.00B - ... }. The
  32. comment indicates when the code is an addition, a deletion, or  a
  33. modification.  Please  note that  there is  only  one  line to be
  34. deleted!
  35.  
  36. NOTES:
  37.  
  38.     
  39.    2.  Make   these   modifications  on  a  COPY  of  the  master               
  40. diskettes, do NOT modify your master diskettes.
  41.  
  42.   The  following  are step-by-step instructions  for  making  the  
  43. modifications:
  44.  
  45.     1. Load the file USER.ED into the Turbo Pascal editor.
  46.     2. At the  bottom of  the variable declaration section add a               
  47. variable of type real:
  48.             .
  49.             .
  50.          Textsave   : Plinedesc;
  51.          Filnam     : String80;
  52.          Buffer     : array [1..Bufsize] of char;
  53.          x          : real;      { Ver. 1.00B - Addition }
  54.  
  55.     3. Modify the call to Turbo Pascal's procedure Reset:
  56.          Change From:
  57.            Reset (Infile);
  58.          To:
  59.            Reset (Infile,1);        { Ver. 1.00B - Modification }
  60.  
  61.     4. Add a line immediately following the call to Reset:
  62.           .
  63.           .
  64.        begin {Reatxtfil}
  65.          Assign (Infile, Fn);
  66.          Reset (Infile,1);          { Ver. 1.00B - Modification }
  67.          x := longfilesize(InFile); { Ver. 1.00B - Addition     }
  68.  
  69.     5. Modify the If-Then statement:
  70.          Change From:
  71.            if Pointer > (Nrecsread * 128) then
  72.            begin
  73.              Blockread (Infile, Buffer, Bufsize div 128,
  74. Nrecsread);
  75.                                    { above  is the single line 
  76. to                                       be deleted }
  77.          To:
  78.            if Pointer > Nrecsread then
  79.            begin                   { Ver. 1.00B - Modification }
  80.              if x > BufSize then   {Need to load another buffer
  81. full}
  82.              begin                 { Ver. 1.00B - addition }
  83.                Blockread (Infile, Buffer, Bufsize, Nrecsread);
  84.                x := x - BufSize;   { Ver. 1.00B - addition }
  85.              end
  86.              else                  { Ver. 1.00B - addition }
  87.                                    { Ver. 1.00B - addition }
  88.                Blockread (Infile, Buffer, trunc(x), Nrecsread);
  89.  
  90.     6. Load the file KCMD.MS into the Turbo Pascal editor.
  91.     7. Repeat steps 2 through 6
  92.