[fpc-pascal]error messages

Pierre Muller pierre at idefix.wisa.be
Tue Sep 19 21:57:53 CEST 2000


At 12:34 19/09/00 GMT, you wrote:
>> procedure ErrorMessage;
>> begin
>>   if ErrorAddr <> nil then
>>     begin
>>       case ExitCode of
>>         1: writeln ('Invalid function number.');
><cut>
>
>>         227: writeln ('Assertion failed error.');
>>         else writeln ('Unknown error.');
>>       end;
>>     end;
>>   Exitproc:=OldExitProc;
>> end;
>
>Small hint: place the ExitProc:=OldExitProc as the first statement in the 
>procedure. If not done and your procedure gives an error it'll get into an 
>infinite loop.

  No exitproc is allways reset to nil before calling next 
exit procedure that is into the chain.
So if an error occurs inside this code, the other exit procedures would not
be 
called, that all, you would get into a infinite loop.

  You can get into an infinite loop of you set exitproc pointer
into a function that gets called more than once, so a good pratice is  
to either write this in the start code of the unit directly
or to do something like

  const
    oldexitproc : pointer = nil;

  if oldexitproc=nil then
    begin
      oldexitproc:=exitproc;
      exitproc:=@myexit_code_function;
    end;








More information about the fpc-pascal mailing list