Run-time error 100 is produced when an application applies the procedure GET to a binary file throughout
Original Reporter info from Mantis: juancdiaz
-
Reporter name: Juan Díaz
Original Reporter info from Mantis: juancdiaz
- Reporter name: Juan Díaz
Description:
When applying the procedure GET to files whose components are of file types other than text and end-of-file is reached,
run-time error 100 is reported. After compiling the following source code and executing the program, the run-time error in
question is produced.
{$mode iso}
program TestGetOnBinaryFiles(fr, output); {runtime error 100 is produced}
const max = 100;
type FileOfReal = file of real;
var fr: FileOfReal;
procedure createfileofreal(var fr: FileOfReal);
var i: 1..max;
r: real;
begin
writeln;
assign(fr, 'RealNumbers.dat');
rewrite(fr);
for i := 1 to max do
begin
r := i * 1.95;
fr^ := r;
put(fr)
end ;
close(fr)
end ;
procedure printfileofreal(var fr: FileOfReal);
begin
writeln;
writeln('Contents of file:');
reset(fr);
while not eof(fr) do
begin
writeln(fr^ :3:2);
get(fr)
end ;
close(fr);
writeln
end ;
begin
createfileofreal(fr);
printfileofreal(fr)
end .
However, when the file is of type text and the procedure GET is used to access all of its components, no run-time error occurs.
{$mode iso}
program TestGetOnTextfiles(f, output); {no run-time error is produced}
var f: text;
ch: char;
begin
writeln;
writeln('Contents of file:');
writeln;
assign(f, 'ATextfile.txt');
reset(f);
while not eof(f) do
begin
ch := f^;
write(ch);
get(f)
end ;
close(f);
writeln
end .
In my humble opinion, this issue should be fixed in order for FPC to comply with the ISO 7185 standard since the following example
from page 31 of the ISO 7185 Pascal standard document also causes the aforementioned run-time error.
procedure CopyFiles (var from, into : FileOfInteger);
begin
reset(from) ; rewrite(into);
while not eof(from) do begin
into^ := from^;
put(into) ; get(from)
end
end { of CopyFiles };
Steps to reproduce:
Compile the source code files attached and run the programs.
Mantis conversion info:
- Mantis ID: 38506
- OS: Windows 7
- Platform: i386
- Version: 3.2.0
- Monitored by: » @KaiBurghardt (Kai Burghardt)