SmartPascal
Begin
Keyword
Keyword that starts a statement block
  begin
    Statements
  end
Description
The Begin keyword is fundamental to Delphi - it starts statement blocks.
 
The Begin-end pair fence in a set of statements. You may place such a block anywhere in your code.
 
It is particularly sensible in if and for statements, even if only one statement is required. It means that adding an additional statement in the future is easy.
 
For example :
 
if a = 7 then do
  Inc(b, a);

 
Is better written :
 
if a = 7 then do
begin
  Inc(b, a);
end;

 
for maintenance purposes.
Related commands
End Keyword that terminates statement blocks
For Starts a loop that executes a finite number of times
Function Defines a subroutine that returns a value
Procedure Defines a subroutine that does not return a value
Repeat Repeat statements until a ternmination condition is met
While Repeat statements whilst a continuation condition is met
 
Example code : Some examples of the begin statement
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  myChars : array[1..2] of char;
  myBytes : array[1..2] of Byte;
  i : Integer;

// The begin statement always starts the code part of a subroutine
Begin
  // Use a for block to assign to both arrays
  for i := 1 to 2 do
  Begin
    myChars[i] := Chr(i+64);
    myBytes[i] := i+64;
  end;

  // Use a for block to observe the contents
  for i := 1 to 2 do
  Begin
    ShowMessage('myChars['+IntToStr(i)+'] = '+myChars[i]);
    ShowMessage('myBytes['+IntToStr(i)+'] = '+IntToStr(myBytes[i]));
  end;
end;
 
end.
Hide full unit code
   myChars[1] = A
   myBytes[1] = 65
   myChars[2] = B
   myChars[2] = 66