[fpc-pascal]blockread in a procedure
dle3ab at angelbase.com
Sun Feb 29 09:24:54 CET 2004
I'm having trouble using blockread. It was working for... oh, a year... and all of a sudden it's not working. I'm getting a runtime error 87 in win32/i386 (fpc 1.0.10) and an error 217 in linux/i386 (fpc 1.0.6). Since I always compile with -gl it tells me it's failing right at blockread. Here's the code...
test_file_name = 'test.txt';
the_source : ansistring = '';
bufsize = 2048;
source_file : file;
buf : array [1..bufsize] of char;
count_read : longint; // longint required by blockread
write ('Reading source file.....');
assign (source_file, test_file_name);
the_source := '';
blockread (source_file, buf, bufsize, count_read);
the_source := the_source + copy (buf, 1, count_read);
until count_read = 0;
the_source := the_source + chr(255);
writeln ('Source file successfully read');
If I get rid of the procedure read_source_file and put its code directly into the main "begin end." then it works. So for some reason, suddenly it can't stand having blockread inside a procedure. I haven't touched the procedure or any of the constants/variables associated with it in a long time, so it's bizarre that it suddenly decided to fail.
Incidentally, fpc 1.0.10 rpm failed to install on redhat. I struggled with it for a good hour. Any tips? Does the gz work better than the rpm?
More information about the fpc-pascal