[fpc-pascal]exception handling

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Mar 21 15:02:07 CET 2004

On 21 mrt 2004, at 14:56, kractor wrote:

>> begin
>>         readln(A);
>>         NewAlbum.Year:=StrToIntDef(A,0);
>>         write('label: ');
>>         readln(NewAlbum.alLabel);
>>         write('tracks: ');
>>         readln(NewAlbum.NumTracks);
>> This avoids the exception.
> just wondering if there's been any progress on this? not trying to 
> pressure or anything, more curious as to what the actual problem was 
> if its been discovered yet ... also wondering if anyone else had this 
> problem besides me?

The problem is simply that "readln" is split into "read" and 
"readline_end". The former reads whatever you want to read, the latter 
consumes the end-of-line. The ioresult is checked after both 
operations. If the read already returned an error, then an exception 
will be raised, so the readln_end is never executed.

That's the way readln (and writeln) was implemented from the start in 
FPC. I don't know if there's an elegant solution possible, or that it 
requires to change the whole way we handle it (e.g. passing a boolean 
to each internal read routine that notes whether or not it should 
consume everything till the end of the current line, no matter what 


More information about the fpc-pascal mailing list