Difference between revisions of "Begin"

From Lazarus wiki
Jump to navigationJump to search
m (Text replace - "delphi>" to "syntaxhighlight>")
Line 3: Line 3:
 
For a function, method, procedure, program, or property, it is used after all [[Const|const]], [[Type|type]] and [[Var|var]] declarations, and before the first executable statement.  It is always terminated by an [[End|end]] statement:
 
For a function, method, procedure, program, or property, it is used after all [[Const|const]], [[Type|type]] and [[Var|var]] declarations, and before the first executable statement.  It is always terminated by an [[End|end]] statement:
  
<delphi>
+
<syntaxhighlight>
 
   program Project1;
 
   program Project1;
 
   var (..);
 
   var (..);
Line 9: Line 9:
 
     (..);
 
     (..);
 
   end.
 
   end.
</delphi>
+
</syntaxhighlight>
  
 
For a block statement, it delineates the top of the block, and is also terminated by an end statement:
 
For a block statement, it delineates the top of the block, and is also terminated by an end statement:
  
<delphi>
+
<syntaxhighlight>
 
   if (..) then
 
   if (..) then
 
     begin
 
     begin
Line 22: Line 22:
 
       (..)
 
       (..)
 
     end;
 
     end;
</delphi>
+
</syntaxhighlight>
  
 
A '''begin''' ''must'' be closed with '''[[End|end]]'''.
 
A '''begin''' ''must'' be closed with '''[[End|end]]'''.
  
 
{{Keywords}}
 
{{Keywords}}

Revision as of 14:56, 24 March 2012

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