Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-02

Unknown RT error

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Does anyone know what a runtime error 998 means? I can't find that one in the docs. The program compiles fine (I'm using Win32), but then when I try to run it I get that odd RT message.

The program is one I'm writing to see if I can read and parse blocks of CR/LF delimited text strings faster then readln can. I've attached a sample that gives the error. A -gl says the problem is on line 51, but that's nothing more then a blockread() command. Can anyone see what the problem is?

TIA...

Jim

Thomas Schatzl
to Unknown author

----- Original Message -----
From:
To:
Sent: Tuesday, February 26, 2002 4:36 PM
Subject: [fpc-pascal]Unknown RT error

Does anyone know what a runtime error 998 means? I can't find that one in the docs. The program compiles fine (I'm using Win32), but then when I try to run it I get that odd RT message.

No.

Show quoted text 6 lines
The program is one I'm writing to see if I can read and parse blocks of CR/LF delimited text strings faster then readln can. I've attached a sample that gives the error. A -gl says the problem is on line 51, but that's nothing more then a blockread() command. Can anyone see what the problem is?

Hmm, my suggestion would be replacing the "reset (BinaryFile);" statement
with a "reset (BinaryFile, 1)" since otherwise blockread tries to read the
data in chunks of 128 Bytes not single bytes, e.g. BUFFERSIZE*128 bytes if
I'm not mistaken.

It seems to work then though. ^^

Hth,
Thomas

Unknown author
Thomas;
Hmm, my suggestion would be replacing the "reset (BinaryFile);" statement with a "reset (BinaryFile, 1)" since otherwise blockread tries to read the data in chunks of 128 Bytes not single bytes, e.g. BUFFERSIZE*128 bytes if I'm not mistaken.

But on my blockread statement I'm using sizeof (Buffer) -- which is a 32K array of char -- to determine the block size to read from the file. I would assume that blockread would then only try to read 32768 bytes, correct? Or is that wrong...

Jim

Thomas Schatzl
to Unknown author

Subject: Re: [fpc-pascal]Unknown RT error

Show quoted text 11 lines
Thomas; >Hmm, my suggestion would be replacing the "reset (BinaryFile);" >statement with a "reset (BinaryFile, 1)" since otherwise blockread >tries to read the data in chunks of 128 Bytes not single bytes, >e.g. BUFFERSIZE*128 bytes if I'm not mistaken. But on my blockread statement I'm using sizeof (Buffer) -- which is a 32K array of char -- to determine the block size to read from the file. I would assume that blockread would then only try to read 32768 bytes, correct? Or is that wrong...

From the documentation (about file handling):
------
"Blockread" reads count or less *records* from file F. A record is a block
of bytes with size specified by the Rewrite() or Reset() statement. [...]

"Reset" opens a file f for reading. [...] If F is an untyped file, the record size can be specified in the optional parameter L. A default value of
128 bytes is used. [...]
------

You didn't open the file as "file of char" or "file of byte" but as an untyped file.... hence the default record size for reading is 128 bytes and
not as expected one byte. The rtl doesn't adjust the i/o record size for each operation. It is set at the time you issue the reset() call and stays
the same while the file is open.

To solve your problem you either have to tell the rtl the default record size (if you use untyped files) or use a typed file handle (the record size
is derived from the typed file type information automatically at runtime)

Changing the declaration of BinaryFile to one of those mentioned should work
too.

The only thing I wasn't sure about was the default record size which I correctly remembered to be 128 bytes.

Thomas