Difference between revisions of "End"
From Lazarus wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | The '''end''' [[keyword]] closes a block of instructions started with the [[begin]] or [[case]] keyword, ends the declaration of [[field]]s of a [[record]], or closes a [[try]] .. [[finally]] or [[try]] .. [[except]] construct. | + | The '''end''' [[keyword]] closes a block of instructions started with the [[begin]] or [[case]] keyword, ends the declaration of [[field]]s of a [[record]], or closes a [[try]] .. [[finally]] or [[try]] .. [[except]] construct. It is also used to close a unit having no initialization code. |
For example: | For example: | ||
Line 24: | Line 24: | ||
'''end'''; | '''end'''; | ||
'''end'''. | '''end'''. | ||
+ | |||
+ | For a UNIT which contains no initialization, 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 '''begin''' statement *) | ||
+ | |||
+ | end. | ||
Revision as of 22:14, 10 May 2006
The end keyword closes a block of instructions started with the begin or case keyword, ends the declaration of fields of a record, or closes a try .. finally or try .. except construct. It is also used to close a unit having no initialization code.
For example:
procedure Proc1; var a,b: integer; begin (..) end;
It is also used to end a pascal source file, in which case it is followed by a period rather than a semicolon (in the example below, the last semicolon is optional):
program Proc2; var SL: TStrings; begin SL := TStringlist.Create; try (..) finally SL.Free; end; end.
For a UNIT which contains no initialization, 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 begin statement *) end.
Keywords: begin — do — else — end — for — if — repeat — then — until — while