Difference between revisions of "Begin"

From Lazarus wiki
Jump to navigationJump to search
(more detail ; wikify)
Line 1: Line 1:
[[keyword]] which starts a program:  
+
The [[keyword]] '''begin''' is used to indicate the start of the executable section of a [[function|FUNCTION]], [[method]] of an [[object|OBJECT]], [[procedure|PROCEDURE]], [[program|PROGRAM]], [[property]] of an object, or is used to delineate the start of a [[block]] statement.
 +
 
 +
For a function, method, procedure, program, or property, it is used after all [[CONST]], [[TYPE]] and [[VAR]] declarations, and before the first executable statement.  It is always terminated by an [[end|END]] statement:
  
 
   '''program''' Project1;
 
   '''program''' Project1;
Line 7: Line 9:
 
   '''end'''.
 
   '''end'''.
  
Or a block of actions:
+
For a block statement, it delineates the top of the block, and is also terminated by an END statement:
  
 
   '''if''' (..)'''then'''
 
   '''if''' (..)'''then'''
Line 18: Line 20:
 
   '''end''';
 
   '''end''';
  
A statement starting with '''begin''' must always be closed with the '''[[end]]''' keyword.
+
A '''begin''' ''must'' be closed with '''[[end]]'''.
  
 
{{Keywords}}
 
{{Keywords}}
  
 
{{Stub}}
 
{{Stub}}

Revision as of 20:45, 10 May 2006

The keyword begin is used to indicate the start of the executable section of a FUNCTION, method of an OBJECT, PROCEDURE, PROGRAM, property of an object, or is used to delineate the start of a block statement.

For a function, method, procedure, program, or property, it is used after all CONST, TYPE and VAR declarations, and before the first executable statement. It is always terminated by an END statement:

 program Project1;
 var(..);
 begin
   (..);
 end.

For a block statement, it delineates the top of the block, and is also terminated by an END statement:

 if (..)then
 begin
   (..)
 end
 else
 begin
   (..)
 end;

A begin must be closed with end.


Keywords: begindoelseendforifrepeatthenuntilwhile

An editor has declared this article to be a stub, meaning that it needs more information. Can you help out and add some? If you have some useful information, you can help the Free Pascal Wiki by clicking on the edit box on the left and expanding this page.