Programming in Object Pascal language

The most important commands from Object Pascal programming language in one place, a unique comparison and each command-operator is shown using a piece of program. Statements-operators of these sample programs are clickable, so with a simple click we have more information available.

Programming language Object Pascal:


Lexical elements

Lexical elements are numeric, string constants and comments in the code.

Types and variables

Types and variables are closely related because variables are the most important elements of our program in which we store data, partial results of our calculations. Types tell us what data can be stored in variables.

Program structure


Operators

Operators perform an operation between the operands, this operation can be mathematical, logical, or bitwise.
Parenthesis operator: ( )

Statements

Statements are important elements for writing programs. Generally one statement line corresponds to one line program. The main group of the statements are: cycles, program branching and flow control.

Object Pascal

 i := x * 5;
 while i>0 do
   if i=10 then
     break
   else 
   begin
     dec(i)
   end;

Examples - Object Pascal

Object Pascal

2 shl 2      
2 shr 2      
$ff and $05 // 0x05
$01 or $02 // 0x03
not 2         
$1A xor $1A 

Object Pascal

5 < 3        //   true
x > 3.14     //   
y <= x       //   ...
$ff >= y    //   ...
x = 6       
y <> 25      

Object Pascal

Other pieces of example codes:
{ x = 20
y = 3 / 2;
 f(5) } 
if x>5 then
  y := x / $a;  // y = 1
if x>$abc then
  y := x / $a;    // y = 466
a or true
128 shl (j shl(3 + i))
y := longword((x * y));
Languages: en hu cz sk