Subject: | |
From: | |
Reply To: | |
Date: | Fri, 10 Jan 1997 00:05:13 MEZ |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Shivanad Hiremath wrote:
>
> I am facing the following strange behaviour of the pascal 'READLN()' and
> 'READ()' functions on the MPE.
>
> Problem description:
> --------------------
>
> There is a file whose record size is greater than 255 bytes. This file can
> be of either fixed length or variable length record type. Now a few lines
> of text is added to this file. Some of these lines have more than 254
> characters in them.
>
> Also there is a Pascal program which I have written, that is supposed to
> open the above mentioned file for input and display the contents of that
> file line by line (ie. record by record) and also the total number of
> characters in each line.
>
> Now I am observing some strange or unexpected behaviour of this small pascal
> program under the following instances of input file:
>
> 1. If a line in the input file has less than 254 characters, then the
> behavior is correct and as expected.
>
> 2. If a line in the input file has more than 254 characters, then the
> call to the pascal readln() function senses an end of line character
> after 254th character and is ignoring the rest of the characters
> from 255 till the end of that record. The next call to readln()
> reads (at the most 254 chars) FROM THE BEGINNING OF THE NEXT RECORD.
>
> Even the behavior of the pascal function read() is the same as above.
> If there are more than 254 characters in a line of record, then
> after the 254th call to the read() function the eoln() is becoming
> true.
>
> Any explaination for this strange behavior?
>
[snip]
There were some interesting comments from Stan, Jeff, Duane, ...
about the Pascal I/O performance, nobody however addressed the problem
described: is Pascal/XL 'readln()' and 'read()' NOT ABLE to read textfiles of
records longer than 254 bytes???
As far as I remember the same limitation also holds for 'write()' and
'writeln()'. I would be very interested to know a work-around!
There are many cases where performance is not an issue (could be a seldom
used program), but simplicity of programming is.
A small example:
I want to write into a text file a number of strings of DIFFERENT size
in a 'comma delimited format' (useful to be imported in some PC programs).
With Pascal I/O I can write:
Do
stringA := ....; stringB := .... ; .... StringZ := ... ;
....
writeln(stringA, stringB, stringC, ..... ,stringZ) ;
until .... ;
To the performance guru's: how many lines of codes do you
need to program the equivalent of the writeln statement using 'fwrite's?
How much MORE time do you need to program and to test your code?
How much is the increase in cost for your company? And, finally, ...
how many readln() can your CPU execute until the additional CPU cost
becomes higher than the additional programming costs?
... and what about program readabilty and maintenance, maybe years later,
by a different programmer?
Kurt Sager
-----------------------------------------------------------------------
Address: E-Mail: Phone:
Kurt Sager [log in to unmask] +41 31 981 0666
SWS SoftWare Systems AG [log in to unmask]
Freiburgstr. 634 [log in to unmask] Fax:
CH-3172 Niederwangen b. Bern Switzerland +41 31 981 3263
=======================================================================
|
|
|