Difference between revisions of "Finally"
From Lazarus wiki
Jump to navigationJump to searchm (Fixed syntax highlighting; improved English translation of German) |
(insert →Caveats) |
||
Line 40: | Line 40: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | == Caveats == | ||
+ | |||
+ | The <syntaxhighlight lang="delphi" inline>finally</syntaxhighlight> part is ''not'' executed if a {{Doc|package=RTL|unit=system|identifier=halt|text=<syntaxhighlight lang="delphi" inline>halt</syntaxhighlight>}} occurred. | ||
== See also == | == See also == |
Revision as of 23:46, 24 June 2020
│
Deutsch (de) │
English (en) │
suomi (fi) │
Back to Reserved words.
The reserved word finally
identifies a block of code that should always be processed, regardless of whether an error has occurred or not.
Examples
Simple example:
begin
...
try
... // code to check
finally
... // code which should always be executed even in case of error
end;
...
end;
Example with error handling:
begin
...
try
try
... // code to check
except
... // error handling
end;
finally
... // code which must always be executed even in case of error
end;
...
end;
Caveats
The finally
part is not executed if a halt
occurred.