Difference between revisions of "End"
From Free Pascal wiki
Jump to navigationJump to searchm (Fixed syntax highlighting; deleted category included in page template) |
(to end do …) |
||
Line 13: | Line 13: | ||
** [[Try, Except and Finally|<syntaxhighlight lang="delphi" enclose="none">try … except … finally … end</syntaxhighlight>]] | ** [[Try, Except and Finally|<syntaxhighlight lang="delphi" enclose="none">try … except … finally … end</syntaxhighlight>]] | ||
* to finish off certain [[Type|type]] declarations, such as [[Object|<syntaxhighlight lang="delphi" enclose="none">object</syntaxhighlight>]], [[Record|<syntaxhighlight lang="pascal" enclose="none">record</syntaxhighlight>]] and [[Class|<syntaxhighlight lang="delphi" enclose="none">class</syntaxhighlight>]] | * to finish off certain [[Type|type]] declarations, such as [[Object|<syntaxhighlight lang="delphi" enclose="none">object</syntaxhighlight>]], [[Record|<syntaxhighlight lang="pascal" enclose="none">record</syntaxhighlight>]] and [[Class|<syntaxhighlight lang="delphi" enclose="none">class</syntaxhighlight>]] | ||
+ | *iIn [[Extended Pascal|extended Pascal]] <syntaxhighlight lang="pascal" inline>to end do …</syntaxhighlight> starts the definition of the [[Finalization|<syntaxhighlight lang="pascal" inline>finalization</syntaxhighlight> part of a module]] | ||
For example: | For example: |
Revision as of 03:19, 23 June 2020
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
The keyword end
terminates an entity.
It appears at several occasions:
- to mark the end of a module, i.e. a
program
,unit
orlibrary
- to conclude a block of statements or instructions respectively
- to wrap up some language constructs:
- most prominently
if … then … end
, or case
…of
…end
, but alsotry … except … finally … end
- most prominently
- to finish off certain type declarations, such as
object
,record
andclass
- iIn extended Pascal
to end do …
starts the definition of thefinalization
part of a module
For example:
procedure proc0;
var
a, b: integer;
begin
…
end;
The end
gloss is one of the exceptions to the rule that every statement must be followed by a semicolon.
The statement immediately preceding an end
does not require a semicolon.
It is also used to end a Pascal module, in which case it is followed by a period rather than a semicolon (in the example below, the last semicolon is optional):
program proc1;
var
SL: TStrings;
begin
SL := TStringlist.create;
try
…
finally
SL.free;
end;
end.
end
is used to indicate the end of the unit:
unit detent;
uses math;
procedure delta(r:real);
implementation
procedure delta;
begin
...
end;
...
(* Note: No corresponding '''begin''' statement *)
end.
It also closes a record:
Type
ExampleRecord = Record
Values: array [1..200] of real;
NumValues: Integer; { holds the actual number of points in the array }
Average: Real { holds the average or mean of the values in the array }
End;
Keywords: begin — do — else — end — for — if — repeat — then — until — while