HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to DelphiVariablesData Types & ConversionOperatorsStringsConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔄 Data Types & Conversion
✍️ String
🔁 Condition & Loop
🧩 Function & Procedure
Delphi›Introduction to Delphi

Introduction to Delphi

First step into Delphi, the classic of rapid application development: program structure and writeln.

Simple enough for a 5-year-old to understand

Structure of a Delphi program

The program starts with "program name;" and ends with "end." (with a period). {$MODE DELPHI} enables Delphi syntax.

Your first program
1
program Hello;
Program name.
DefinitionProgram name.
2
{$MODE DELPHI}
Delphi compatible mode.
ImportDelphi compatible mode.
3
begin
Main block start.
DefinitionMain block start.
4
writeln('Hello!');
Writer (text SINGLE quotes).
Output / InputWriter (text SINGLE quotes).
5
end.
End of program — with a PERIOD.
DefinitionEnd of program — with a PERIOD.
DefinitionImportOutput / Input
💡 Hint: Strings are in single quotes: 'Hello'. The program ends with end. (dot).

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print Hello World to the screen exactly.

🎯 Expected output: Hello World

Loading editor…

About this topic

Delphi is a development environment that uses the Object Pascal language. Released by Borland in 1995, it became known as the fastest way to write GUI applications for Windows; the idea of dragging and dropping components onto a form originated from here.

As a language, Delphi preserves Pascal's structural discipline while adding classes, inheritance, exceptions, and interfaces. The compiler translates directly to machine code; it does not need a virtual machine, so executable files are standalone.

Today, Delphi is still common in desktop business applications, accounting, and inventory software. In Turkey, many commercial programs are powered by Delphi, and maintaining this code is a real necessity.

What you will learn

  • Program and unit structure
  • Writing a console application
  • The role of the uses clause
  • The separation of interface and implementation
  • Compiler directives

Who is this for?

  • Those who know Pascal and are transitioning to object orientation
  • Those who want to develop desktop applications
  • Those maintaining legacy Delphi projects

When to use?

When you need to write fast, standalone desktop applications for Windows, Delphi is still very efficient; interface design and database access are combined in a single environment.

It is not preferred for new web projects; in this area, the ecosystem has gathered around other languages.

Common mistakes

Wrong

program Test;
begin
  writeln('Hello');
end.

In a console application, if you do not tell the compiler that this is a console program, the resulting file is considered a windowed application and printed outputs will not appear anywhere. The appropriate compiler directive must be added after the program header.

Correct

program Test;

{$APPTYPE CONSOLE}

begin
  writeln('Hello');
end.

Wrong

program Test;

{$APPTYPE CONSOLE}

begin
  writeln(IntToStr(42));
end.

The conversion function is defined in a standard library unit; since the unit is not declared in the uses clause, an "Undeclared identifier" error is received. In Delphi, every function belongs to a unit, and that unit must be explicitly included for use.

Correct

program Test;

{$APPTYPE CONSOLE}

uses
  SysUtils;

begin
  writeln(IntToStr(42));
end.

Wrong

program Test;

{$APPTYPE CONSOLE}

begin
  writeln('Hello');
end;

The main program file ends with a period, not a semicolon. This is a rule inherited from Pascal, and forgetting to put a period after the final end is a beginner's first compilation error.

Correct

program Test;

{$APPTYPE CONSOLE}

begin
  writeln('Hello');
end.

Frequently asked questions

What is a unit?

It is the way to split code into files in Delphi. Each unit consists of an interface section and an implementation section: the interface contains what is exposed externally, while the implementation contains the bodies. This separation also shortens compilation time.

Are Delphi and Free Pascal the same?

They are not the same, but largely compatible. Free Pascal offers a Delphi compatibility mode, and the Lazarus environment provides a form designer very similar to Delphi. It is a free option for those who want to work cross-platform.

The console application window closes immediately, what should I do?

The window closes when the program finishes. During development, you can make it wait by adding a line-reading call at the end to see the output; or run the application directly from the command line.

Summary

Delphi uses Object Pascal.

Console applications require a compiler directive.

Functions belong to units and are imported with uses.

Units are separated into interface and implementation sections.

The main program ends with a period.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code