Keep in mind that although we have covered a number of language constructs in this chapter, these constructs represent only a fraction of all the language constructs in Object Pascal (for instance, we haven't even gotten to the ones that put the word "Object" in "Object Pascal"). These are only the most basic constructs necessary to get started with programming. This section should provide a quick reference as you move on to future chapters for all of the basic concepts we have covered so far.
Concept
Example
Debugging
To set a breakpoint click the margin

F9 = Start Run or Continue if paused

F8 = Step Single Line

F7 = Step Into
Built-in Subroutines
Writeln('Answer to life, ',
  'the universe, and everything = ',4,X);
Readln;
Other Common Subroutines
Refer to Section 2.7 for more details.
Declarations
var
  VariableName : VariableType;

const
  ConstantName = ConstantValue;
  ConstantName : ConstantType = ConstantValue;
Operators
:=       // Assignment
+ - * /  // Add subtract multiply divide
div      // Integer division
mod      // Modular division
and      // Logical and (TRUE and FALSE = FALSE)
or       // Logical or
         //   (TRUE or FALSE = TRUE)
         //   (TRUE or TRUE = TRUE)
xor      // Logical exclusive or
         //   (TRUE xor FALSE = TRUE)
         //   (TRUE or TRUE = FALSE)
not      // Logical negation
>        // Greater than
>=       // Greater than or equal
<        // Less than
<=       // Less than or equal
=        // Equal to
<>       // Not equal to
Conditional Statements
if Condition then
  StatementForTrueCondition
else StatementForFalseCondition;

case OrdinalExpression of
  ConstantExpr1: Statement1;
  ConstantExpr2: Statement2;
  ...
  ConstantExprN: StatementN;
  else OtherwiseStatement;
end;
Loop Statements
for ControlVariable := Start to Stop do
begin
end

for ControlVariable := Stop downto Start do
begin
end

while Condition do
begin
end

repeat
until Condition

Break
Continue
Subroutine Declarations
procedure ProcedureName(Argument1Name : Argument1Type;
  Argument2Name, Argument3Name : Argument2And3SameType);
begin
  {Code to be executed}
end;

function FunctionName(Argument1Name : Argument1Type;
  Argument2Name : Argument2Type) : FunctionResultType;
begin
  {Code to be executed}
  Result := ReturnValue;
end;
Unit Declarations
unit UnitName;
interface
uses {Units used by interface here};

implementation
uses {Units used by implementation here};

initialization
{Optional initialization section.}
finalization
{Optional finalization section.}
end.