Difference between revisions of "Talk:sysutils"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "I do not think we should try to "duplicate" the fpc docs here? bart 2016-07-03 17:10 CET.")
 
Line 1: Line 1:
 
I do not think we should try to "duplicate" the fpc docs here? [[user:bart|bart]] 2016-07-03 17:10 CET.
 
I do not think we should try to "duplicate" the fpc docs here? [[user:bart|bart]] 2016-07-03 17:10 CET.
 +
 +
 +
"To catch an exception by its name you will need to include sysUtils in every unit that may throw an exception"<br>
 +
That makes no sense whatsoever.
 +
<syntaxhighlight lang=pascal>
 +
unit divzero;
 +
 +
interface
 +
 +
procedure DoDivByZero;
 +
 +
implementation
 +
 +
procedure DoDivByZero;
 +
var
 +
  A, B: Integer;
 +
begin
 +
  A := 1;
 +
  B := 0;
 +
  A := A div B;
 +
end;
 +
 +
end.</syntaxhighlight>
 +
 +
This unit does NOT include sysutils.<br>
 +
If you call it from the main program, <b>and</b> your main program uses SysUtils, then you can catch the exception by name: "EDivByZero:  Division by zero". --[[User:Bart|Bart]] ([[User talk:Bart|talk]]) 13:47, 23 January 2021 (CET)

Revision as of 14:47, 23 January 2021

I do not think we should try to "duplicate" the fpc docs here? bart 2016-07-03 17:10 CET.


"To catch an exception by its name you will need to include sysUtils in every unit that may throw an exception"
That makes no sense whatsoever.

unit divzero;

interface

procedure DoDivByZero;

implementation

procedure DoDivByZero;
var
  A, B: Integer;
begin
  A := 1;
  B := 0;
  A := A div B;
end;

end.

This unit does NOT include sysutils.
If you call it from the main program, and your main program uses SysUtils, then you can catch the exception by name: "EDivByZero: Division by zero". --Bart (talk) 13:47, 23 January 2021 (CET)