I am just playing with an old Pure Pascal app I wrote years ago to do some processing of MyMail files.
It needs strings longer than the Pascal 255 ones so I implemented a 1024 char string.
It is read char by char but I have hit problems with testing EOF(file), it is causing a runtime 100 error. I tried changing it from a file of char to a file of byte without success.
I've refreshed my rusty Pascal knowledge. Thorsten is right! Runtime error 100 means that you tried to read past EOF. I.e., if you're already at the end of the file, try to read from it and have IO exceptions enabled ({$I+} directive), you get runtime error 100. You have to check for EOF before trying to read.
EDIT: From the PurePascal help file (I only have it in German):
Runtime error 100: disk read error
------------------------------------------------------------------
Der Laufzeitfehler 'disk read error' wird erzeugt, wenn versucht
wird, mittels Read über das Ende einer typisierten Datei hinaus-
zulesen.
PeterS wrote:EOF didn't work so I had to test for a 0 in the returned content. It looks like PP eof only works in text files.
It works just fine with a "File of Byte", too! You just have to test for EOF before reading the next byte -- as mentioned multiple times in this thread.
This will read the entire PP.CFG, byte by byte, without triggering a Runtime Error 100.
Description The SetTextBuf procedure assigns a text file
variable a new size I / O buffer
size too. The specification of size is optional.
Text file variables have one by default
I / O buffer with 128 bytes size. Intervenes
Program frequently towards a text file, so
this the program speed clearly
decrease because many (relatively slow)
accesses to the data carrier are necessary.
Therefore, a larger block is always in
read a buffer or from a buffer
written, so a speed
increase can be achieved. SetTextBuf can
install a larger I / O buffer.
Warning: SetTextBuf must never be on one
open file will be applied!
Cross references
Read Write text
Example var
t: text;
c: Char;
buf: Array [1..8192] of Char;
begin
Assign (t, 'TEST.TXT');
SetTextBuf (t, buf);
Reset (t);
while not Eof (t) do begin
Read (t, c);
Write (c);
end;
Close (t);
end.
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!