Delphi tutorial: Hello world
This tutorial helps you get started with Delphi. It explains what you need to write your first Delphi program. It starts with the basics: you will learn where you can find and download the tools needed, how to install these tools and it will take you all the way to building and running your code. If you have never written a Delphi program before this is the place to start. We have created this article, so you can get started with Delphi, and move on to our sms examples. If you are already familiar with Delphi, you can jump directly to one of the following SMS projects.
Delphi sms examples:
Delphi send sms with the HTTP rest api (code sample)
Delphi send multiple sms with the HTTP rest api (code sample)
Delphi schedule sms with the HTTP rest api (code sample)
Delphi receive sms with the HTTP rest api (code sample)
Delphi delete sms with the HTTP rest api (code sample)
Download the latest Delphi sms api library from Github
What is Delphi
Delphi is a programming language. It is similar to a natural language, like English. It is used to talk to a computer. The major difference between a natural language and a programming language is that programming languages have a more rigorous structure, to help the computer understand it better.
What is Delphi Community Edition
Delphi Community Edition is a tool to write a Delphi program. Delphi Community Edition allows you to type in text using the Delphi language, and it makes it possible for you to tell the computer, to read the text and execute the instructions. We use the term "Run" to tell computer to execute the instructions.
What is a Delphi Hello world program
The Delphi hello world program is the simplest program you can write. It simply prints out the sentence: Hello world on the computer screen. The Hello World program is the first program developers write in any programming language.
How to write your first program in Delphi
To write your first program in Delphi:
- Setup Delphi Community Edition
- Create a new project in Delphi
- Select Console Application - Delphi
- Write Hello World program in Delphi
- Use WriteLn() for printing
- Run your Delphi Hello World program
- Check the output
- Fix the errors if there is any
Prerequisites
Here is what you need to get started. To write your first computer program in Delphi, you need a Windows computer, the Delphi Community Edition programming environment and example code presented below.
- Windows 10 computer
- Register to https://embarcadero.com/
- Delphi Community Edition Community Edition
- Ozeki Hello World example project
Download Delphi Community Edition
Delphi Community Edition Community EditionIn this video, you are going to see how you can download the Delphi Community edition software. You will start with visiting the download page and the video will take you all the way to having the installer on your computer locally. It is only 26-seconds-long, but it features all the steps you need to take to finish the process. You need the Delphi IDE to get started with coding in Delphi. The URL of the download page: https://embarcadero.com/products/delphi/starter/free-download/
Install Delphi Community Edition
You are going to see how to install the Delphi community edition on your computer in this video. It will start with the downloaded installer and will take you all the way to having the Delphi IDE on your computer. The video is only 1:22 long but it offers all the steps in a detailed way. You will have no problem with following the steps. You will see how to run the installer and what settings you need to do before installing the IDE.
Create your first Delphi Community Edition project
In the next video, you are going to see how to create your first Delphi project. To edit or create new code, you need a project. The video will start with an opened Delphi Community edition and will end with a default project that can be edited freely. The video is only 15 seconds and easy to understand. You will have no problem understanding it. Having a project means that you can create and run Delphi codes easily.
Create new project
To start coding in Delphi you first need to open Delphi Community edition. Then, you need to click on the File tab on the top left (Figure 1). Next, inside the File menu, hover your cursor over New. From New, select Console Application - Delphi by clicking on it. This will bring you straight to the text editor, where you can start coding.
Write your 'hello world' program in Delphi
The first program you write in any programming language is the 'Hello world' program. The sole aim of this program is to print the term 'Hello world' to the computer screen. In this example the program consists of two lines of code: The first line: WriteLn(); prints the text.
program Project2; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; begin try WriteLn('Hello world!'); ReadLn; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
Write your 'hello world' program in Delphi (Video tutorial)
The first program that a programmer creates is always a ‘Hello World’ program. It means that the output of the code is simply ‘Hello World’. In this video, we are going to show you how you can create this first code in Delphi. The video is only 15-seconds-long, but you will see all the steps you need. You will see where to write the code and what is the code exactly. The video will begin with a default project screen and will end with the runnable program.
Run the Delphi 'hello world' program
To run the hello world program, you need to click on the green Start button in the Delphi Community Edition toolbar. You may also use the F5 key to run your program. Note that when you press F9, Delphi Community Edition will first save your newly written file, then it will compile it to an executable code, and then it will run it on your computer.
Run the program
Now that you wrote your program in the text editor, you can execute it using the IDE. Click on the terminal icon with the green play button next to it in the top toolbar to run your program (Figure 2). Clicking this button will bring up a debug console and execute your lines of code inside of it.
Output of your code
Once your program ran, you can see the output in the debug console (Figure 3). Here we can see that inside the console, the "Hello World!" message is displayed. This indicates that your program ran as intended. Next, we're going to take a look at what happens when it encounters an error.
What happens if I make a mistake in Delphi
If you make a mistake, when you write your instructions in Delphi, you will get a Syntax error. The computer will highlight the line with error in red, and it will tell you why it didn't understand the instructions. To correct the mistake, you need to go back to the text editor and modify the program. Programs say they "fix the error" when they correct mistakes.
What is syntax error in Delphi?
Syntax error means I don't understand. If you talk to somebody in English and he does not understand what you say, he will reply with "I don't understand". If you talk to a computer in Delphi and the computer does not understand what you say, he will reply with "Syntax error".
In the code below we will create a mistake intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
How to handle a syntax error in Delphi?
In this video, you are going to see how an error in a delphi code looks like. In the code below we will create a syntax error intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully. The video is only 35-seconds-long and it features all the elements of correcting a mistake.
Error
If your code fails to run for some reason, an error message pops up in a new window (Figure 4). This window notifies the developer of the error, as well as provides information about the nature of the error. This way it is easier for the programmer to identify mistakes in the code and fix them.
Summary
By reading this article, you have obtained valuable information on how to get ready for coding in Delphi and how to build and run your first Hello World code. If you have followed the instructions above and successfully welcomed the World, you have made your first step in becoming a Delphi software developer. Now you can use the Ozeki Delphi SMS solutions which will help you in message organization very effectively, because you can customize the given codes without any limitations.
Learn more about developing your messaging system by using Delphi solutions. Move on to the next tutorial about how to send SMS from Delphi.
Download the Ozeki SMS Gateway now and put into practice what you have learned!
More information
- C# SMS tutorial: Hello world
- Visual Basic SMS tutorial: Hello world
- F# SMS tutorial: Hello world
- Java SMS tutorial: Hello world
- Javascript SMS tutorial: Hello world
- Node.js SMS tutorial: Hello world
- Kotlin SMS tutorial: Hello world
- C/C SMS tutorial: Hello world
- Delphi SMS tutorial: Hello world
- PHP SMS tutorial: Hello world
- Perl SMS tutorial: Hello world
- Python SMS tutorial: Hello world
- Python flask SMS tutorial: Hello world
- Ruby SMS tutorial: Hello world
- Tcl/Tk SMS tutorial: Hello world
- Go SMS tutorial: Hello world
- R SMS tutorial: Hello world
- Scala SMS tutorial: Hello world
- Objective C SMS tutorial: Hello world
- Tutorials for software developers