Board index » delphi » Error 100 : Disk read error.

Error 100 : Disk read error.

Quote
>             I am a collage student doing my project. I have a problem when
> copying a file to another file. The source file was save in the harddisk
> which I can open it using my display Program. Whenever I try to copy this
> file, I always get this message (Error 100 : Disk read error). For your
> infor, I using turbo pascal version 7 running on Pentium(Win98) and on Dos
> enviroment. For your reference here are the copying program that I use.

> Program Copyfile;
> Uses Crt;
> Type Account = Record
>                  StudNo : 1..9999;
>                  Name   : String;
>                  balance : Real
>                End;
> Var OldAcct,NewAcct : Account;
> NewStudents,Oldstudents : FILE OF Account;
> Begin
>   Assign(Oldstudents,'Sample.Dat'); Assign(NewStudents,'List.Dat');
>   Reset(OldStudents); Rewrite(NewStudents);
>   While Not eof(OldStudents) Do
>     Begin
>       Read(OldStudents,OldAcct); NewAcct := OldAcct;
>       Write(NewStudents,NewAcct)
>     End;

    Close OldStudents); Close (NewStudents)

Quote
> End.

   Even from this complete problem description, I can't be sure what the
problem is.  The code look okay (except you don't close the files after
processing), and it should work.  That fact that it doesn't leads me to
believe you have a "mismatch" between your data definition (the record
description) and the actual file data being processed.  If there was less
data on each file record than you've defined, you would indeed get an
error such as you're receiving.
   I am particularly interested in your declaration of "Name": you're
using a string (which is actually "string[255]"), and I hardly think it's
what you really have in the data file.  I feel you should seek out and
determine the precise data definition you're using and adjust your record
definition accordingly.
   BTW, if you are only _copying_ a data file, you don't need to do it at
the record level, one at a time.  It's far easier and better to use
BlockRead/BlockWrite to do a generic copy of one file to another, and you
don't have to deal with file content specifics...
 

Re:Error 100 : Disk read error.


JRS:  In article <MPG.1362914758ab101f989...@news.primenet.com> of Sat,
15 Apr 2000 14:47:06 seen in news:comp.lang.pascal.borland, Mike

Quote
Copeland <mrc...@primenet.com> wrote:
>>             I am a collage student doing my project. I have a problem when
>> copying a file to another file. The source file was save in the harddisk
>> which I can open it using my display Program. Whenever I try to copy this
>> file, I always get this message (Error 100 : Disk read error). For your
>> infor, I using turbo pascal version 7 running on Pentium(Win98) and on Dos
>> enviroment. For your reference here are the copying program that I use.

>> Program Copyfile;
>> Uses Crt;
>> Type Account = Record
>>                  StudNo : 1..9999;
>>                  Name   : String;
>>                  balance : Real
>>                End;
>> Var OldAcct,NewAcct : Account;
>> NewStudents,Oldstudents : FILE OF Account;
>> Begin
>>   Assign(Oldstudents,'Sample.Dat'); Assign(NewStudents,'List.Dat');
>>   Reset(OldStudents); Rewrite(NewStudents);
>>   While Not eof(OldStudents) Do
>>     Begin
>>       Read(OldStudents,OldAcct); NewAcct := OldAcct;
>>       Write(NewStudents,NewAcct)
>>     End;
>    Close OldStudents); Close (NewStudents)
>> End.

>   Even from this complete problem description, I can't be sure what the
>problem is.  The code look okay (except you don't close the files after
>processing), and it should work.  That fact that it doesn't leads me to
>believe you have a "mismatch" between your data definition (the record
>description) and the actual file data being processed.  If there was less
>data on each file record than you've defined, you would indeed get an
>error such as you're receiving.

Does that matter?  Nothing is done with the contents of OldAcct, except
for (unnecessary) duplication.  Every Read should eat 2+256+6 bytes (is
this a case where Reset needs a ", 1"?  I suspect so) regardless of the
actual pattern of the data.

Quote
>   I am particularly interested in your declaration of "Name": you're
>using a string (which is actually "string[255]"), and I hardly think it's
>what you really have in the data file.  I feel you should seek out and
>determine the precise data definition you're using and adjust your record
>definition accordingly.

Well, it's *his* data file, I think.

Quote
>   BTW, if you are only _copying_ a data file, you don't need to do it at
>the record level, one at a time.  It's far easier and better to use
>BlockRead/BlockWrite to do a generic copy of one file to another, and you
>don't have to deal with file content specifics...

Yes, the *REAL* error is that he hasn't read TSFAQP #62.  Someone should
write a note for the Malaysian Teacher's Journal, or whatever - we get a
lot from .my.

I did wonder, given Win98 & Crt, whether the "100" might be a typo for
"200".

As usual, he does not say whether Run-Time checks are on; nor at what
exact stage of the program the error occurs - the easy thing is to
insert Write statements, or single-step with the integrated de{*word*81} -
it should be at the read statement, of course.

Now if the record size is wrong, because of no "1" in Reset (Rewrite?)
or otherwise, and the input has a non-integer record count, then such
use of EoF means that a full read of a part record will be attempted ;
100 seems a likely error number for this.

=

In checking TP7, I just noticed something : ERATOST3.PAS has what I
thought was a Data Segment array as large as possible (given the program
also has 2 longints).  It appears that when compiling to memory, it's
too big (error 49), but to disc is OK.  Program was written with BP7;
IIRC, a difference in array size between MSDOS & DPMI modes too.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.

Re:Error 100 : Disk read error.


Dear sir,
            I am a collage student doing my project. I have a problem when
copying a file to another file. The source file was save in the harddisk
which I can open it using my display Program. Whenever I try to copy this
file, I always get this message (Error 100 : Disk read error). For your
infor, I using turbo pascal version 7 running on Pentium(Win98) and on Dos
enviroment. For your reference here are the copying program that I use.

Program Copyfile;
Uses Crt;

Type Account = Record
  StudNo : I..9999;
  Name : String;
  balance   Real;
  End;
Var OldAcct,NewAcct   Account;
NewStudents,Oldstudents : FILE OF Account;

Begin
Assign(Oldstudents,'Sample.Dat');
Assign(NewStudents,'List.Dat');
Reset(OldStudents);
Rewrite(NewStudents);
While Not eof(OldStudents) Do
    Begin
         Read(OldStudents,OldAcct);
         NewAcct := OldAcct;
         Write(NewStudents,NewAcct);
    End;
End.
Please help.

Thank    you

Freddie

Other Threads