Difference between revisions of "Finally"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 
{{Finally}}
 
{{Finally}}
  
The [[Reserved word]] '''finally''' identifies the block that should always be processed, regardless of whether an error has occurred or not.
+
The [[Reserved word]] <syntaxhighlight lang="pascal" enclose="none">finally</syntaxhighlight> identifies the [[Block|block]] that should always be processed, regardless of whether an error has occurred or not.
  
 
Example:
 
Example:
Line 15: Line 15:
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>
<br>
 
  
  
Example (in this example, the finally block is always executed)::<br>
+
Example (in this example, the <syntaxhighlight lang="pascal" enclose="none">finally</syntaxhighlight> block is always executed):
 +
 
 
<syntaxhighlight>
 
<syntaxhighlight>
 
begin
 
begin
Line 34: Line 34:
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>
<br>
+
 
 
== See also ==
 
== See also ==
  

Revision as of 20:41, 20 March 2019

Deutsch (de) English (en) suomi (fi)

The Reserved word finally identifies the block that should always be processed, regardless of whether an error has occurred or not.

Example:

begin
  ...
  try
    ... // Action
  finally
    ... // Final work, which should be done even in case of error
  end;
  ...
end;


Example (in this example, the finally block is always executed):

begin
  ...
  try
    try
      ... // instructions to check
    except // error handling
      ...
    end;
  finally // always instructions to be processed
    ...
  end;
  ...
end;

See also