home *** CD-ROM | disk | FTP | other *** search
- PRODUCT : TURBO EDITOR TOOLBOX NUMBER : 245
- VERSION : 1.00A
- OS : PC-DOS
- DATE : March 13, 1986
-
- TITLE : FILE TRUNCATION UPDATE FROM VERSION 1.00A TO 1.00B
-
- The changes to the Turbo Editor Toolbox described in this
- handout prevent the truncation of files when they are read from
- disk. The Reset procedure in Turbo Pascal 3.0 provides a second
- optional parameter that defines the size of a block when using
- untyped files. By setting the block size to 1 byte, you are able
- to determine the exact number of characters to be read by
- calling Turbo Pascal's function, LongFileSize. You can then
- perform blockreads of the exact amount of bytes and avoid reading
- too many or too few bytes from disk. Please see the READ.ME
- file in your manual or on your Turbo Pascal diskette for
- additional information about the optional Reset parameter.
-
- The routine to be modified is called:
-
- procedure EditReatxtfil (Fn : Varstring);
-
- This routine exists in two files:
-
- KCMD.MS, on the MicroStar Source diskette
- USER.ED, on the .COM Files, Turbo Editor Toolbox SOURCE
- diskette
-
- The modified lines of code are listed in the routine below
- with a comment at the end of the line: { Ver. 1.00B - ... }. The
- comment indicates when the code is an addition, a deletion, or a
- modification. Please note that there is only one line to be
- deleted!
-
- NOTES:
-
-
- 2. Make these modifications on a COPY of the master
- diskettes, do NOT modify your master diskettes.
-
- The following are step-by-step instructions for making the
- modifications:
-
- 1. Load the file USER.ED into the Turbo Pascal editor.
- 2. At the bottom of the variable declaration section add a
- variable of type real:
- .
- .
- Textsave : Plinedesc;
- Filnam : String80;
- Buffer : array [1..Bufsize] of char;
- x : real; { Ver. 1.00B - Addition }
-
- 3. Modify the call to Turbo Pascal's procedure Reset:
- Change From:
- Reset (Infile);
- To:
- Reset (Infile,1); { Ver. 1.00B - Modification }
-
- 4. Add a line immediately following the call to Reset:
- .
- .
- begin {Reatxtfil}
- Assign (Infile, Fn);
- Reset (Infile,1); { Ver. 1.00B - Modification }
- x := longfilesize(InFile); { Ver. 1.00B - Addition }
-
- 5. Modify the If-Then statement:
- Change From:
- if Pointer > (Nrecsread * 128) then
- begin
- Blockread (Infile, Buffer, Bufsize div 128,
- Nrecsread);
- { above is the single line
- to be deleted }
- To:
- if Pointer > Nrecsread then
- begin { Ver. 1.00B - Modification }
- if x > BufSize then {Need to load another buffer
- full}
- begin { Ver. 1.00B - addition }
- Blockread (Infile, Buffer, Bufsize, Nrecsread);
- x := x - BufSize; { Ver. 1.00B - addition }
- end
- else { Ver. 1.00B - addition }
- { Ver. 1.00B - addition }
- Blockread (Infile, Buffer, trunc(x), Nrecsread);
-
- 6. Load the file KCMD.MS into the Turbo Pascal editor.
- 7. Repeat steps 2 through 6
-