LearnStanmorephysics

Grade 10 · Delphi Foundations

Welcome to Delphi & the IDE

Grade 10 · Meet Delphi · Lesson and quiz · about 8 minutes

Take this lesson in the app →

Welcome! If you take Information Technology in Grades 10–12, Delphi is the language you will live in for the next three years — it is the language used in the CAPS curriculum and in the NSC practical exams.

How a Delphi program fits together

Delphi programs are event-driven: you design a form (a window) with components on it, and then write code that runs when an event happens — usually when the user clicks a button. In the IDE you will work with four main areas:

  • Form Designer — where you drag components onto your form and arrange them.
  • Object Inspector — where you change a component's properties (like Name, Caption and Text) and hook up its events.
  • Code Editor — where you type your Object Pascal code.
  • Tool Palette — the list of components you can add (TButton, TEdit, TLabel, TMemo …). Older Delphi versions at some schools call this the Component Palette — same thing.

Double-click a button on the form and Delphi creates an event handler for you — a procedure with a name like btnCalculateClick — and that is where your code goes.

Naming conventions (very important!)

South African IT classes use prefixes so that you can see at a glance what something is. Markers expect them, so make them a habit from day one:

ComponentPrefixExample
FormfrmfrmQuiz
Button (TButton)btnbtnCalculate
Edit box (TEdit)edtedtName
Label (TLabel)lbllblAnswer
Memo (TMemo)memmemOutput
Panel (TPanel)pnlpnlHeader

Variables get prefixes too: i for Integer (iCount), r for Real (rPrice), s for String (sName), c for Char (cGrade) and b for Boolean (bFound).

Exam tip. In the practical paper you are given a project with components already named this way. Reading edtAge and instantly knowing "edit box holding an age" saves you minutes.

Quick check before we write code:

Quick check

Question 1

You want to change a button's Caption from "Button1" to "Calculate". Where do you do that?

  1. The Code Editor
  2. The Object Inspector
  3. The Tool Palette
  4. The Windows Control Panel
Answer

The Object Inspector — Properties like Name and Caption are changed in the Object Inspector (or in code, e.g. btnGo.Caption := 'Calculate').

Question 2

Which is the best name for an edit box where the user types their surname?

  1. Edit1
  2. btnSurname
  3. edtSurname
  4. surname
Answer

edtSurname — The edt prefix tells everyone it is a TEdit, and Surname says what it holds. Edit1 tells you nothing, and btn would mean a button.

Question 3

Delphi programs run code when the user clicks buttons or types. This style of programming is called…

  1. batch programming
  2. event-driven programming
  3. machine code
  4. spreadsheet modelling
Answer

event-driven programming — Code sits in event handlers and waits for events (like OnClick) to happen — event-driven.

Question 4

You double-click btnStart on the form. What does Delphi create in the Code Editor?

  1. A new form
  2. A variable named btnStart
  3. A copy of the button
  4. An event handler procedure named btnStartClick
Answer

An event handler procedure named btnStartClick — Double-clicking a component creates its default event handler — for a button that is the OnClick handler, e.g. procedure TfrmMain.btnStartClick(Sender: TObject);

About this material

This platform provides original CAPS-aligned practice material and study tools. Content is machine-verified and has not been reviewed by subject specialists. It is not affiliated with or endorsed by the Department of Basic Education. Learners should also use official past papers and consult their teachers where uncertain.