Wednesday, 14 April 2010

Delphi Tutorial # 5

Program Structure

A program is composed of three elements :

- Program Title

- Uses Clauses

- Declarations and Statements

Program title is the name of the program. Uses clauses include units that are used in the program. Declarations and statements are codes that will be executed by computer.

You can see an example of Delphi program structure in Delphi Tutorial # 2. See the codes project1.dpr file  below :

    program Project1;



      Unit1 in 'Unit1.pas' {MyForm};

    {$R *.RES}



      Application.CreateForm(TMyForm, MyForm);



The example above does not have declarations. Declaration is where we define constants, types, variables, procedures and functions. The structure of declarations is shown below :


           {constants list}


          {types create by user}


          {variables list}

          {functions and procedures}

Function is a routine that can be called by the program and will return a value. Procedure is a routine that does not return a value.

A program is usually formed by some source code modules that called units. A unit consist some routine (functions and procedures). It is saved as a unit file (.PAS). The structure of a unit is shown below :

       Unit unitname;


       Uses {units}



       Uses {units}







The example of a unit is unit1.pas file :

    unit Unit1;



      Windows, Messages, SysUtils, Classes, Graphics, Controls,           Forms, Dialogs, StdCtrls;


      TMyForm = class(TForm)

        Label1: TLabel;

        ExitButton: TButton;

        procedure ExitButtonClick(Sender: TObject);


        { Private declarations }


        { Public declarations }



      MyForm: TMyForm;


    {$R *.DFM}

    procedure TMyForm.ExitButtonClick(Sender: TObject);





Go to Previous Tutorial or Next Tutorial


  1. Hello Ari, thanks for your visit and for the comment left. I picked up those pictures free on internet.. so I think there's no problem to use them in a non-commercial manner. Wish you all the best!

  2. Thank you Ana, for visiting my blog. wish you all the best too..

  3. mantab sobat, aq masih belum ngeh dengan delphi...klo bisa share software nya juga dong, oh ya delphi itu prinsipnya sama ndak dengan VB atau SQL?

  4. sobat....klo tidak keberatan saya nantikan kehadiranya di blog saya dan kesediaanya untuk bergabung di dalam forum, nampaknya delphi adalah materi baru yang belum kami miliki deh....

  5. @Aditya : Delphi is quite the same with VB, it's an OOP and a visual programming. But Delphi based on Pascal Language. SQL is for database. Delphi and VB is usually for creating a user interface that is connected to a database server (interbase, mysql, firebird etc)
    Arbitter : Ok :-)


These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.