[fpc-pascal]exception handling issue

kractor baron.kractor at cogeco.ca
Mon Aug 30 02:36:22 CEST 2004


having some problems with exception handling that have me pretty 
confused .... i'll include below the entire procedure where the 
exception handling occurs ...

     Procedure procAddNewAlbum;
         Var
             tmpAlbumName : AnsiString;
             tmpAlbumID : Longint;
             tmpNumTracks : Smallint;
             tmpLabel : AnsiString;
             tmpYear : Integer;
         Begin
             Write ('album name: ');
             ReadLn (tmpAlbumName);
             tmpAlbumID := ID_Generator;
             Write ('tracks: ');
             Try
                 ReadLn (tmpNumTracks);
             Except
                 On E: EInOutError do tmpNumTracks := 0;
             End;
             WriteLn ('tmpNumTracks = ',tmpNumTracks);
             Write ('label: ');
             ReadLn (tmpLabel);
             Write ('year: ');
             Try
                 ReadLn (tmpYear);
             Except
                 tmpYear := 0;
             End;
         End;

now, if i enter anything for tmpNumTracks that's not numeric (and 
therefore raises the exception) the following happens ...

	album name: test
	tracks: g
	tmpNumTracks = 0
	label: year: ^C

the exception code appears to be executed, but when the program "exits" 
the exception block it seems to be processing one line, then skipping 
one, then proceeding as normal ... i don't *think* i've made any syntax 
mistakes, and if i have i'm going to look rather silly ... :D




More information about the fpc-pascal mailing list