Difference between revisions of "Finally"
From Lazarus wiki
Jump to navigationJump to searchm (Fixed syntax highlighting; improved English translation of German) |
|||
Line 1: | Line 1: | ||
{{Finally}} | {{Finally}} | ||
− | |||
− | + | Back to [[Reserved words]]. | |
− | <syntaxhighlight> | + | |
+ | |||
+ | The reserved word <syntaxhighlight lang="pascal" enclose="none">finally</syntaxhighlight> identifies a [[Block|block]] of code that should always be processed, regardless of whether an error has occurred or not. | ||
+ | |||
+ | == Examples == | ||
+ | |||
+ | Simple example: | ||
+ | |||
+ | <syntaxhighlight lang=pascal> | ||
begin | begin | ||
... | ... | ||
try | try | ||
− | ... // | + | ... // code to check |
finally | finally | ||
− | ... // | + | ... // code which should always be executed even in case of error |
end; | end; | ||
... | ... | ||
Line 16: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | Example with error handling: | ||
− | + | <syntaxhighlight lang=pascal> | |
− | |||
− | |||
begin | begin | ||
... | ... | ||
try | try | ||
try | try | ||
− | ... // | + | ... // code to check |
− | except | + | except |
− | ... | + | ... // error handling |
end; | end; | ||
− | finally | + | finally |
− | ... | + | ... // code which must always be executed even in case of error |
end; | end; | ||
... | ... |
Revision as of 00:50, 16 February 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;