Difference between revisions of "Finally"
From Lazarus wiki
Jump to navigationJump to search (insert →Caveats) |
|||
Line 5: | Line 5: | ||
− | The reserved word <syntaxhighlight lang="pascal" | + | The reserved word <syntaxhighlight lang="pascal" inline>finally</syntaxhighlight> identifies a [[Block|block]] of code that should always be processed, regardless of whether an error has occurred or not. |
== Examples == | == Examples == |
Revision as of 17:21, 6 August 2022
│
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.