# IT Practical LB Gr11 WEB

> Grade 11 Information Technology textbook, 252 pages. Read online or get the free PDF download.

- Page: https://www.hlayiso.com/library/it-practical-lb-gr11-web/9bb35b6a-7531-4d3c-a17b-2adc64685e2b
- Updated: 2026-10-10
- Subject: Information Technology
- Grade: Grade 11
- Document type: Textbook
- Publisher: Study Guides
- Curriculum: CAPS
- Pages: 252

Breadcrumbs: [Home](https://www.hlayiso.com/) › [Library](https://www.hlayiso.com/library) › [Grade 11](https://www.hlayiso.com/library/grade-11) › [Information Technology](https://www.hlayiso.com/library/grade-11/information-technology) › [IT Practical LB Gr11 WEB](https://www.hlayiso.com/library/it-practical-lb-gr11-web/9bb35b6a-7531-4d3c-a17b-2adc64685e2b)

## About this document

Information Technology · Grade 11. Textbook, 252 pages. Read online or download the PDF.

Read it free online on the page above; download the PDF from there.

## Document text

Text extracted from the PDF. Layout, diagrams and tables may not survive extraction.

### Page 1

Practical Book

INFORMATION
TECHNOLOGY

           CAPS

### Page 2

MTN South Africa, through MTN SA Foundation, is a proud supporter of the CAT and IT digital books.

 As an organisation rooted in technology, we believe in providing a new bold digital world to communities we
  operate in. This unique digital book provides the fundamental knowledge necessary for a sound grounding
     from which to make practical use of the complete and indispensable application-oriented information
   regarding Computer Applications Technology (CAT) and Information Technology (IT). It is a foundational
reference for today’s secondary school learners and teachers alike - as well as for the next generation of CAT
                                                and IT students.

                             Information Technology Practical Book Grade 11
                                         ISBN 978-1-928388-53-1
             First published in 2019 © 2019. Copyright in the text remains with the contributors.

                           Quality Assurance team for Information Technology
            Allison Philander, Carina Labuscagne, David Peens, Denise van Wyk, Edward Gentle,
                 Jugdeshchand Sewnanen, Julian Carstens, Magdalena Brits, Shamiel Dramat,
                                     Shani Nunkumar and Zainab Karriem

                                               Restrictions
You may not make copies of this book in part or in full – in printed or electronic or audio or video form – for a
                                         profit seeking purpose.

                                      Rights of other copyright holders
All reasonable efforts have been made to ensure that materials included are not already copyrighted to other
entities, or in a small number of cases, to seek permission from and acknowledge copyright holders. In some
  cases, this may not have been possible. The publishers welcome the opportunity to redress this with any
                                      unacknowledged copyright holders.

### Page 3

Contents

Term 1                                                                                                                                           Chapter 6                       User-defined methods
                                                                                                                                                 Introduction. ............................................................................................................................ 129
Chapter 1                         Grade 10 Revision and Mathematical
                                   Functions                                                                                                     Unit 6.1 Introduction to user-defined methods. ................................ 130

Introduction. ............................................................................................................................   1   Unit 6.2 Procedures. ................................................................................................. 132

Unit 1.1 Errors, debugging and mathematical methods...........                                                                               2   Unit 6.3 Functions....................................................................................................... 144

Unit 1.2 Mathematical methods. ....................................................................                                          6   Unit 6.4 Basic input validation techniques............................................. 148

Consolidation activity.................................................................................................... 13                    Consolidation activity.................................................................................................... 152

Chapter 2                         Nested loops
                                                                                                                                                 Term 4
Introduction. ............................................................................................................................ 19
Unit 2.1 Nested Loops............................................................................................ 20                             Chapter 7                       User interfaces

Unit 2.2 Using nested loops............................................................................... 26                                    Introduction. ............................................................................................................................ 155

Unit 2.3 Creating shapes using nested loops. ................................... 34                                                              Unit 7.1 Multi-form user interfaces.............................................................. 156

Consolidation activity.................................................................................................... 37                    Unit 7.2 Dynamic Instantiation of objects............................................... 162

                                                                                                                                                 Chapter 8                       Databases
Term 2                                                                                                                                           Introduction. ............................................................................................................................ 167

Chapter 3                         Arrays                                                                                                         Unit 8.1 Creating a database. ........................................................................... 168

Introduction. ............................................................................................................................ 41    Unit 8.2 Connecting to a database.............................................................. 172

Unit 3.1 Arrays. .............................................................................................................. 42               Unit 8.3 Reading data from a database. ................................................. 178

Unit 3.2 Searching and sorting arrays. ..................................................... 55                                                  Unit 8.4 Writing data to a database. ........................................................... 182

Unit 3.3 Parallel arrays. ........................................................................................... 64                         Unit 8.5 Manipulating data. ................................................................................. 188

Consolidation activity.................................................................................................... 67                    Consolidation activity.................................................................................................... 198

Chapter 4                         String and date manipulation
                                                                                                                                                 Annexure A – Grade 10 Revision                                                                                                     201
Introduction. ............................................................................................................................ 69
Unit 4.1 Built-in string methods...................................................................... 70
                                                                                                                                                 Annexure B – Naming convention of components 238
Unit 4.2 Delimited strings. .................................................................................... 86
Unit 4.3 Built-in Date-Time methods......................................................... 90
                                                                                                                                                 Annexure C – Programming and visible characters240
Consolidation activity.................................................................................................... 97

                                                                                                                                                 Glossary243
Term 3

Chapter 5                         Text files                                                                                                     QR Code list                                                                                                                       245
Introduction. ............................................................................................................................ 101
Unit 5.1 Introduction to text files. ................................................................... 102
Unit 5.2 Reading from a text file.................................................................... 106
Unit 5.3 Writing to a text file. ............................................................................. 112
Unit 5.4 Creating reports....................................................................................... 121
Consolidation activity.................................................................................................... 124

### Page 4

Dear Learner
Welcome to the IT Practical Grade 11 textbook, and welcome to programming.

If this is your first time learning how to program, don’t worry. This textbook has been designed to teach anyone –
regardless of experience – how to program. If you follow along with all the examples then you will be an
experienced programmer who has written more than 50 programs by the end of this book.

Programming and programming languages, much like real languages, can only be learned through practice.
You cannot sit at home and learn to speak French from a textbook. In the same way, you cannot read this book
and hope to be a programmer at the end of it. Instead, you will need to write every bit of code and create every
program shown in this book. Even if all you do is follow the steps of the examples on your own computer, you
will learn how to write code. Once you have mastered the code, you will be able to comfortably use it in your
own programs.

For you to master programming, try to work through as many of the programs given to you. Each program has
been designed to both teach you new concepts and reinforce existing concepts. The book will start by teaching
you how to create simple programs. However, by the end of the book you will be creating useful programs and
fun games to play.

Programming is not only about knowing and using the programming language. There are also important
theoretical concepts that you will need to understand, and planning and problem-solving tools that you will need
to master. The best-coded program in the world will not be useful if it solves the wrong problem. This book has
therefore been divided into the following chapters:
●● Chapter 1: Errors, debugging and mathematical methods
●● Chapter 2: Nested loops                                                             WHAT MOST SCHOOLS
●● Chapter 3: Arrays                                                                        DON’T TEACH
●● Chapter 4: String and date manipulation
●● Chapter 5: Text files
●● Chapter 6: User-defined methods
●● Chapter 7: User interfaces
●● Chapter 8: Databases

Before getting started with algorithms, watch the video in the QR code.
                                                                                        https://www.youtube.com/
                                                                                          watch?v=nKIu9yen5nc

### Page 5

To give you the most opportunities to learn, this book will give three types of programming activities:
       UNIT

Examples2.3 Creating shapes using nested loops
Examples will guide you through the creation of a program from start to finish. All you need to do with examples
is to follow the step-by-step   guidance provided to you.
                      You can create simple geometrical shapes using special characters such as ‘*’
                                  or digits.

                                     Example 2.1             Create the shape below using the special character ‘*’

                                    We know that there are six rows and each row has 6 *s. The code to draw this shape:
                                    ******
                                    ******
                                    ******
                                    ******
                                    ******
                                    ******

                                         Line 1:            for i := 1 to 6 do
                                         Line 2:            begin
                                         Line 3:            sLine := ’’;
                                         Line 4:               for j := 1 to 6 do
                                         Line 5:               sLine := sLine +’*’;
                                         Line 6:               memDisplay.Lines.Add(sLine);
                                         Line 7:            end;

                                    Note:
                                    ●●    Line 1: The outer i-loop will run six times because there are six rows.
                                    ●●    Line 3: String sLine is set to null for each row.
Guided activities                   ●●    Line 4-5: In each row, 6 *’s must be joined together.
                                    ●●    Line 6: Display the string sLine before Guided
                                                                                    moving activity
                                                                                            to the next
                                                                                                     2.1row.
Guided activities have a program
                                                      You need to develop a multiplication table for a primary school learner as shown below:
that you need to create     on your Creating a shape
                        Example 2.2
                                                      1×1=1                2×1=2
own. Your teacher will provide
                      We know that there are six rows 1and
                                                         × 2each
                                                             = 2row has 6 2*s.× 2
                                                                               The= 4
                                                                                   code to draw this shape:
you with the solution.*
                              These
                                                      1×3=3                2×3=6
solutions should be **used as an                      You are required to create the 1 times and 2 times multiplication table. In the 1 times multiplication table, you only need
opportunity to compare***        your                 to find the product of 1 multiplied by a multiplier from 1 to 3. This is also true for the 2 times multiplication table.
                      ****                            Let’s create an algorithm and flowchart for the problem.
program, and to see *****
                        where you
may have made errors  The codeor    leftthis shape: ALGORITHM
                               to create                                                                               FLOWCHART
                                                        for I = 1 to 2
something out.          Line 1:         for i := 1 to 5 do
                                                         begin
                                                                                                                                          Start

                        Line 2:         begin
                   IMPLEMENTATION OF
                        Line 3:
                                              INPUT VALIDATION
                                          sLine := ’’;
                                                                for J = 1 to 3                                                                         1
                                                                                                                                                            I←1
                    Input validation                            begin different ways:
                          Line 4: can be for  implemented
                                                    j := 1 intoseveral
                                                                  i do
                       One   way 5:
                                  to implement   input:=validation     Answer
                                                                           inform=the  I*user
                                                                                           J of the problem
                    ●●    Line                 sLine       sLine is to
                                                                    +’*’;                                                           2
                                                                       Display I,’*’, J, ‘=’, answer                         I <= 2           Stop
                       before
                          Linethey6: try to process the data. This     could be in the form of an error
                                               memDisplay.Lines.Add(sLine);                                                         False
                                                                end
                          Line 7:
                       message             end; button with an error message.
                                   or a disabled                                                                                    3
                                                           end
                    ●● A second way of implementing input validation is to check the data before it                          J←1
Activities                                               The I-loop isyou
                       is processed. With this implementation,          the build
                                                                            outer certain
                                                                                   loop. checks or
                                                                                                                                                                                                  8
Activities are programs     that your
                       conditional           teacher
                                     statements           can
                                                  into your
                                                         The      give
                                                            program
                                                             J-loop      theto
                                                                      is to      you
                                                                            ensure
                                                                             inner    thatas
                                                                                    loop.     classroom
                                                                                           you do not process activities or homework.
                                                                                                                             J <= 3
                                                                                                                                    4
                                                                                                                                         With these
                                                                                                                                               I←J+1
                       incorrect data. When these The  statements   identify   incorrect data, you send a                           False
programs, you will only be assessed on how well your program works, so use your creativity to come
                                                             I-loop will  run twice.                                                        up   with
                       message informing the user of the problem.                                                                   5
                                                                             The J-loop will run three times.
a solution!                                                                                                                                           Answer ← I * J
                                                                             The statements within the J-loop will be executed
34   INFORMATION TECHNOLOGY I GRADE 11 I Practical Book
                                                                                                                                                                              6
                                                                             six times.
                                                                                                                                                             Display
                                             Activity 1.1                                                                                            I, '*', J, '=', Answer

                                                                                                                                                                              7
                              1.7.1 What is the difference between syntax, runtime and logic errors?
                                                                                                                                                          J←J+1
                              1.7.2 Give two examples of each of the following errors:
                                         a. Syntax errors
                                         b. Runtime errors              The nested loop executes in the following manner:
                                         c. Logic errors                ●●     When the outer loop is executed for the first time, it triggers the execution of the inner loop. Control is transferred
                                                                               from the outer loop to the inner loop. The inner loop executes from its initial value to its end value and control is
                                                                               transferred back to the outer loop.
                                                                        ●●     For each change of value of the outer loop value, the inner loop is triggered. This process continues until the outer
                                                                               loop reaches its end value.
                                                                        ●●     Therefore in the example above, the inner loop will be triggered twice and for each trigger, the inner loop is executed
                                                                               three times.

### Page 6

●●   Rang
                                                                                                                                                                                  range
                                                                                                                                             Activity 1.9                         valida

                                                                                                                                  1.9.1 Open the SquareCubeRoot_p project and
                                                                                                                                          [Calculate] button to do the following: if
                                                                                                                                          ●●  Generate a random number in the rang
                          ‘Take note’ and ‘Did you know’ boxes                                                                                                                        Els
                                                                                                                                          ●●  Display the random number in the EditB
                          The boxes provide extra, interesting content                                                                        For each number from 1 to the random
                                                                                                   Take note                              ●●

                          that might caution you to ‘take note’ of                                                                         Didsquare,
                                                                                                                                                you know cube and square root of the num
                          something important; or give you additional                     If you cannot see all the                           number,     its square,cube  and square roo
                                                                                                                                     In general, it is better  to
                          information. Note that the content in the                       lines that you have                                 values    must   be formatted
                                                                                                                                                                                 ●● Patte
                                                                                                                                                                             to two decima
                                                                                                                                     prevent a user from making
                                                                                          generated in the Memo                               Save                                  spec
                          ‘Did you know’ boxes will not be part of                                                                   a mistake
                                                                                                                                          ●●
                                                                                                                                                thanand     run the project.
                                                                                                                                                       to inform
                                                                                          component, then you need                                                                that t
                          your exams.                                                                                                the user that they have
                                                                                          to set the ScrollBars                                                                   follow
                                                                                                                                     made a mistake afterwards.
                                                                                          property to ssVertical.                                                                 stop
tinued

sers Folder.
ed in a text file Users.txt.
put the system at risk.
erting dummy data                                                                                                         UNIT 1.9.2 Open  the CircleAreaCircum_p project and
                                                                                                                                     Calculate button to read the radius of a circ
                                       New words                  New words                                                4area and
                                                                                                                                 INFORMATION        of theI GRADE
                                                                                                                                             TECHNOLOGY
                                                                                                                                     circumference                  TheI Pr
                                                                                                                                                            circle. 11   fo
 ded text. For                 obfuscated – the                   These are difficult words that you may not have1.1
                                                                                                                  encountered before.
                                                                                                                            ●●  Area
                                                                                                                                      Errors, debugging and va
                                                                                                                                                  :         π r2
                               deliberate act of creating         A brief explanation for these words are given.
                               source or machine code
                                                                                                                            ●●  Circumference :             2π r
       K    n      U
                               that is difficult for humans                                                                     Save and run your program.
       9   10      11
                               to understand                                                                                                      Programming errors can gener
                                                                                                                                                  errors, runtime errors and logic e
                                                                                                                 WHAT’S AN
                                                                                                                ALGORITHM?                        Syntax refers to the rules of the
                                                                                                                                                  this includes the rules that all sta
                                                                                                                                                  the colon-equals operator (:=) is
 to:                                                                                                                                              you break the rules of the progra
not exist, display an error message and terminate the                                                                     1.9.3 Open the LearnerAlphabet_p file from you
                                  QR Codes, Videos and Screen captures                                                                  Common syntax errors include:
                                                                                                                                allocated   in the following manner to each le
                                  These will link you to online content. When you                                                       ●●    Leaving out a semicolon at th
m the file each time the loop runs.are in the eBook, you can easily access the links.                                           Learner●1:● Z              Learner 2: Xat the en
                                                                                                                                              Adding a semicolon
rs at even positions in the extracted line.                                                         https://www.youtube.com/    Learner 3: V(for example,  Learner
                                                                                                                                                                in an4: T
                                                                                                                                                                        IF-THEN-…
                                                                                            Take note watch?v=6hfOvs8pY1k
RichEditBox.                                                                                                                                  Leaving out the command “v
                                                                                                                                Do the following:
                                                                                                                                        ● ●
                                                                                  If you cannot see all the                                   Assigning
                                                                                                                                                 OnCreatea event
                                                                                                                                                              variable    using th
                                                                                                                                        ●●
                                                                                  lines that you have
                                                                                                                                ●●  Create an                        to initialise   va
                                                                                                                                    of the
                                                                                                                                        ●●    Making
                                                                                                                                             alphabet    a typing
                                                                                                                                                        that will bemistake
                                                                                                                                                                      assigned   intoth
                                                                                  generated in the Memo
                                                                                                                                    the ●first
                                                                                                                                          ●   Not  surrounding strings with
                                                                                                                                               learner.
                         Consolidation activities                                 component, then you need
                                                                                                                                ●●  Create
                                                                                                                                        ●●    Supplying
                                                                                                                                              an OnClick    variables
                                                                                                                                                            event        to a
                                                                                                                                                                   for the      func
                                                                                                                                                                            Genera
                                                                                  to set in
                         This is a revision activity based on what you have covered      thethe
                                                                                             ScrollBars
                                                                                                 chapter. Take time to answer the questions on
                                                                                                                                              incorrect    number
                                                                                                                                    next line of the sequence.        of  variables
                         your own. You teacher may also use these to assess your  property to  ssVertical. during class.
                                                                                          performance
                                                                                                                                                  With Delphi, RAD Studio will p
                                                                                                                                                  Structure panel at the top left Co
                                      CONSOLIDATION ACTIVITY         Chapter 1: Grade 10 Revision and Mathematical Functions                      try to run the program. Double c
                                                                                                                                                  jump to the line with the problem
                                      QUESTION 1 GENERAL PROGRAMMING SKILLS

                                      INSTRUCTIONS
                                      Open the incomplete program in the Question1_1 folder found in the Question 1 folder.
                                      Add your name and surname as a comment in the first line of the Question1_1_u.pas file.
                                      Compile and execute the program. The program currently has no functionality.
                                                                                              12     INFORMATION TECHNOLOGY I GRADE 11 I Practical Book

                                        SCENARIO
der.                                 Congratulations! You have been selected to take part in your schools Cricket tour in New Zealand in the
hey interact with a work computer. Details on users
                                     upcoming         have holidays. Unfortunately, there are some costs involved and your parents have stated that
                                                 December
contains delimited data formatted as you
                                     follows:
                                          will have to come up with some of the money yourself. Fortunately, you are an IT student and are able to
                                     use the skills you have learnt in IT to raise some funds.

### Page 7

TERM 1

ERRORS, DEBUGGING AND                                                                                    CHAPTER

MATHEMATICAL METHODS                                                                                         1
 CHAPTER UNITS
 Unit 1.1:   Errors, debugging and validation
 Unit 1.2:   Mathematical methods

 Learning outcomes
 At the end of this chapter you should be able to:
 ●●  consolidate your knowledge of the work done in Grade 10
 ●●  use the different mathematical methods: Random(), RandomRange(), Round(),
     Trunc(), Frac(), Ceil(), Floor(), Sqr(), Sqrt(), Inc(), Dec(), Pi and Power()
 ●●  use the mathematical methods to solve programs.

INTRODUCTION
This chapter serves to consolidate all the knowledge you acquired in your
Grade 10 studies (also see Annexure A for more Grade 10 revision). It also
focuses on new content that includes work on mathematical methods. You will
use these mathematical methods to solve problems during this year.

                                                         term 1 I Chapter 1 Errors, debugging and mathematical methods   1

### Page 8

UNIT

              1.1          Errors, debugging and validation

                                      Programming errors can generally be grouped into three categories: syntax
                                      errors, runtime errors and logic errors.
     WHAT’S AN
    ALGORITHM?                        Syntax refers to the rules of the programming language. For example, in Delphi,
                                      this includes the rules that all statements have to end with a semicolon and that
                                      the colon-equals operator (:=) is used to assign values. Syntax errors occur when
                                      you break the rules of the programming language.

                                      Common syntax errors include:
                                      ●● Leaving out a semicolon at the end of a statement.
                                      ●● Adding a semicolon at the end of a line which is not the end of a statement
https://www.youtube.com/                 (for example, in an IF-THEN-ELSE statement).
  watch?v=6hfOvs8pY1k                 ●● Leaving out the command “var” when declaring variables.
                                      ●● Assigning a variable using the equals sign.
                                      ●● Making a typing mistake in the name of a variable.
                                      ●● Not surrounding strings with the single quotation marks.
                                      ●● Supplying variables to a function in the incorrect order or supplying an
                                         incorrect number of variables to a function.

                                      With Delphi, RAD Studio will provide you with information on the error in the
                                      Structure panel at the top left Code screen, as well as in the compiler when you
                                      try to run the program. Double clicking on the mistake in the Structure panel will
                                      jump to the line with the problem.

                                      Figure 1.1: The Structure panel will inform you of most syntax mistakes

                                      Runtime errors occur when you ask your program to do a task that is either
                                      impossible or is impossible under certain circumstances. In most instances,
                                      runtime errors will cause your program to crash. Runtime errors can occur in
                                      almost any program, but some examples include:
                                      ●● Doing mathematical calculations on strings.
                                      ●● Performing illegal mathematical operations (such as dividing numbers by 0)
                                      ●● Reading and using values from empty textboxes.
                                      ●● Reading a list value that has not been created.
                                      ●● Activating a ListBox’s OnClick event when nothing is selected.
                                      ●● Combining strings and numbers without changing their data types.

    2    INFORMATION TECHNOLOGY I GRADE 11 I Practical Book

### Page 9

One way to solve a runtime error is to step through your program. You can also search for the error code
online to see if it helps you to identify the cause of the error.

Figure 1.2: Error 102 is caused by a file assignment problem

The final, and most difficult errors to solve are logic errors. These errors occur when there is a logical error
or design problem in your program. While logic errors can cause applications to crash or give error
messages, the program can also work without issue but give incorrect answers.

One way to identify a logic error is to use RAD Studio to track the value of the variable with the incorrect
result. By seeing how the value changes with each step of the application, you can usually identify the
point at which the mistake occurs. You will learn more about this technique in a later chapter.

VALIDATING DATA
Data validation is a technique used by programmers to check (or validate) the information that users enter
before processing it. This allows programmers to prevent common errors from occurring by making sure
that the information entered is correct before it is used. The goal of input validation is to prevent users from
accidentally or purposefully entering incorrect data into your program.

If your program automatically generates the data it will use, you can test
the data before using it. You can also improve the algorithm generating the                         New words
data to ensure that only the correct types of data are generated for your
                                                                                            step through – to step
program.
                                                                                            through means that you are
                                                                                            working through a program
In contrast, when a user is asked to supply data for your program, many                     line by line
unpredictable things can happen. The user may have:
                                                                                            validate – to try and lessen
●●  misunderstood what data is expected
                                                                                            the number of errors during
●●  clicked the next button without entering data                                           the process of data input in
●●  entered the correct data in an incorrect format                                         programming
●●  entered the correct type of data, but an incorrect value.

This incorrect data can cause your application to crash, or even worse, provide incorrect output.

                    term 1 I Chapter 1 Errors, debugging and mathematical methods I Unit 1.1 Errors, debugging and validation   3

### Page 10

DIFFERENT TYPES OF INPUT VALIDATION
                                         You can use different types of input validation in your program, including:
                                         ●● Required input validation prevents the processing until certain required
          Take note                         inputs are given. When you must read a value and perform a calculation
']' refers to a null/empty                  from an Edit component, you may want to test whether the Edit component
string.                                     has a value before proceeding with calculations.

                                                   ….
                                               if edtAmount.text = '' then
                                                     ShowMessage('Enter a value')
                                               Else
                                                    rAmount := StrToFloat(edtAmount.text);
                                                   ….

                                         ●●   Type validation ensures that the data entered is the correct data type. In
                                              your calculator application, you could prevent the user from entering any
                                              values that are not numbers. Alternatively, you could inform the user that an
                                              invalid input was entered if he or she tries to do a calculation with letters and
                                              request them to enter the correct data.
                                         ●●   Length validation ensures that the data entered is the correct length.

                                         Note
                                         The Length function determines the length of a string.

                                                   ….
                                                   sPassword := edtPassword.text;
                                               if length (sPassword) >= 8 then
                                                     ….
                                               Else
                                                    rAmount := StrToFloat(edtAmount.text);
                                                   ….

                                         ●●   Range validation is used to ensure that number or date falls within a specific
                                              range. For example, in a form asking a user’s age, you might use range
                                              validation to ensure the user’s age is between 0 and 120.

                                                   iAge := StrToInt(edtAge.text);
                                               if (iAge > 0) AND (iAge < 120) then
                                                     ….
                                               Else
                                                    ShowMessage('Enter an age in the range 1 to 119');
         Did you know                              ….

In general, it is better to              ●●   Pattern matching validation ensures that the data entered matches a
prevent a user from making
                                              specific pattern. For example, all email addresses would match the pattern
a mistake than to inform
                                              that they contain a bunch of letters or numbers, followed by an “@” sign,
the user that they have
made a mistake afterwards.                    followed by more letters or numbers, followed by one or two groups of a full
                                              stop with letters.

     4      INFORMATION TECHNOLOGY I GRADE 11 I Practical Book

### Page 11

IMPLEMENTATION OF INPUT VALIDATION
Input validation can be implemented in several different ways:
●● One way to implement input validation is to inform the user of the problem
   before they try to process the data. This could be in the form of an error
   message or a disabled button with an error message.
●● A second way of implementing input validation is to check the data before it
   is processed. With this implementation, you build certain checks or
   conditional statements into your program to ensure that you do not process
   incorrect data. When these statements identify incorrect data, you send a
   message informing the user of the problem.

          Activity 1.1

1.7.1 What is the difference between syntax, runtime and logic errors?
1.7.2 Give two examples of each of the following errors:
       a. Syntax errors
       b. Runtime errors
       c. Logic errors

                     term 1 I Chapter 1 Errors, debugging and mathematical methods I Unit 1.1 Errors, debugging and validation   5

### Page 12

UNIT

         1.2             Mathematical methods

    METHODS
    A method is a segment of pre-written programming code that performs a specific task. Methods are
    written by the developers of Delphi. There are two types of methods: functions and procedures. You have
    already worked with the data conversion functions IntToStr, FloatToStr, StringToFloat and StringToInt as
    well as formatting functions FloatToStrF and Format. In this chapter, we will discuss mathematical functions
    ROUND, TRUNC, FRAC, CEIL, FLOOR, SQR, SQRT and PI and the procedures INC and DEC.

    Methods are provided in Units for use by programmers. For example, the Math Unit hosts a collection of
    mathematical functions. The names of the Units that the programmers are most likely to use are
    automatically included in the Uses clause of the Unit of the Form.

    You can determine from which Unit a function or procedure is, by hovering you mouse over the function
    or procedure name. A tooltip appears displaying the information about the function or procedure. If you
    hover on the StrToInt function the tooltip below will appear:
       StrToInt function is found in the SysUtils unit

                 Parameter – type of information
                 the function is expecting from the
                 user before execution

                         Return type of the function

    When a programmer uses a function or procedure and the Unit name of the function or procedure does
    NOT appear in the Uses clause, then a compiler error will occur. The programmer needs to add the name
    of the Unit to the Uses clause. For example, if you are using the functions from the Math Unit then you
    have to add the Math Unit to the Uses clause:

                 uses
                   Windows, Messages, SysUtils, Variants, Classes, Graphics,
                   
                   Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Math;

    If you do not know the Unit name of the function or procedure, then do the following:
    ●●  Type the name of the function or procedure in the Delphi editor.
    ●●  Click on the name of the function or procedure you type in the bullet above.
    ●●  Press <Ctrl> + <F1> simultaneously.
    ●●  Delphi Help will provide you with the information of the function or procedure.

    Functions and procedures can be called from any part of a program. When the functions or procedures
    are called, control from the program is transferred to the function or procedure. The programming code
    for the function or procedure is then executed. Once the programming code for the function or procedure
    terminates, control is transferred back to the main program.

6   INFORMATION TECHNOLOGY I GRADE 11 I Practical Book

### Page 13

IMPORTANT INFORMATION ABOUT FUNCTIONS
Delphi prewritten functions can be called from any part of a program. A function is always called within
another statement and returns a single value. For example:

The StrToInt function in the statement below is called in an assignment statement and returns an
integer value.
			iNum := StrToInt(edtValue.Text);

PREDEFINED MATHEMATICAL FUNCTIONS

RANDOM() FUNCTION
You learnt about the Random function in Grade 10. The RANDOM function generates a random number
from 0 to less than 1.
         rNumber := Random()

If you want to generate a number from a to b, then use the formula:
         iNumber := Random(b – a + 1) + a

Example: To generate a random number in the range 10 to 99 the code is:
       iNumber := Random(90) + 10

RANDOMRANGE() FUNCTION
Syntax: RandomRange(Num1,Num2)
The RandomRange function generates a random integer number from Num1 to one less than Num2.
Example:
        iNum := RandomRange(1,7);

This statement will generate a random integer number from 1 to 6.

ROUND() FUNCTION
The Round function rounds a real number to an integer value.

The ‘Banker’s Rounding’ method is used for rounding numbers. The real number X is rounded to the
nearest whole number. If X is exactly halfway between two whole numbers, the result is always the even
number of the two whole numbers.

For example:
        rX := 14.5;
        iAns := Round(rX);

Steps to complete the rounding:
●● Step 1: Establish between which two whole numbers rX lies. Example 14.5 lies between 14 and 15
●● Step 2: Establish whether rX lies exactly halfway between the two whole numbers. In this case 14.5
            lies exactly halfway between 14 and 15
●● Step 3:
   {{ If rX lies exactly halfway, then round to the nearest even whole number. In this case 14.5 will be

       rounded down to 14
   {{ If rX does not lie exactly halfway between the two whole numbers, then round normally according

       to mathematical rules to the nearest whole number

                         term 1 I Chapter 1 Errors, debugging and mathematical methods I Unit 1.2 Mathematical methods   7

Text truncated here. Open the document page to read the rest.

## Related documents

- [IT P1 QP GR11 NOV 2022 English](https://www.hlayiso.com/library/it-p1-qp-gr11-nov-2022-english/3db564bd-1d04-48ab-aedd-fae2d9f9939f) — Information Technology · QP · 2022 · Eng
- [IT P2 GR11 QP NOV2022 Afrikaans](https://www.hlayiso.com/library/it-p2-gr11-qp-nov2022-afrikaans/00d1cb8c-b0d9-41ea-9060-a94b73039d3a) — Information Technology · QP · 2022 · Afr
- [IT P2 GR11 QP NOV2022 English](https://www.hlayiso.com/library/it-p2-gr11-qp-nov2022-english/1c12dccc-2a5b-4b41-a80c-5bd8b30f6151) — Information Technology · QP · 2022 · Eng
- [IT P1 MEMO GR11 NOV 2022 AFR](https://www.hlayiso.com/library/grade-11-information-technology-2022-exemplar-november-exam-memorandum-paper-1-afrikaans/02cbecc3-c4be-49dd-986d-125a0173594d) — Information Technology · Memo · 2022 · Afr
- [IT P1 QP GR11 NOV 2022 AFR](https://www.hlayiso.com/library/grade-11-information-technology-2022-exemplar-november-exam-question-paper-paper-1-afrikaans/a17870ba-8fac-4013-9eda-0831f367fbca) — Information Technology · QP · 2022 · Afr
- [IT P1 QP GR11 NOV 2022 English](https://www.hlayiso.com/library/grade-11-information-technology-2022-exemplar-november-exam-question-paper-paper-1-english/c2d16637-c6bc-43d6-b469-cb62712d9eb0) — Information Technology · QP · 2022 · Eng

## More from Grade 11 Information Technology

- [IT P2 GR11 QP NOV2022 Afrikaans](https://www.hlayiso.com/library/grade-11-information-technology-2022-exemplar-november-exam-question-paper-paper-2-afrikaans/be8f522c-a9ab-4a0d-bbce-f1b478d57356) — QP · 2022 · Afr
- [IT P2 GR11 QP NOV2022 English](https://www.hlayiso.com/library/grade-11-information-technology-2022-exemplar-november-exam-question-paper-paper-2-english/b3f6c643-27fc-4fd5-baa3-b8c49c4b6f61) — QP · 2022 · Eng
- [GEO-Sept-QP & Memo-2015-Gr11](https://www.hlayiso.com/library/geo-sept-qp-memo-2015-gr11/cfa849fa-4151-4938-b293-d0122c3a72c6) — QP + Memo · 2021
- [IT P1 MEMO GR11 NOV 2020 Afrikaans](https://www.hlayiso.com/library/it-p1-memo-gr11-nov-2020-afrikaans/b58d463e-025c-4716-9255-6eeeebfafbc3) — Memo · 2020 · Afr
- [IT P1 MEMO GR11 NOV 2020 Afrikaans D](https://www.hlayiso.com/library/it-p1-memo-gr11-nov-2020-afrikaans-d/25d21533-ac81-4ade-a4b8-c56f655e7a81) — Memo · 2020 · Afr
- [IT P1 QP MEMO GR11 NOV2020 Afrikaans D](https://www.hlayiso.com/library/it-p1-qp-memo-gr11-nov2020-afrikaans-d/09d5bea3-08be-4b20-9a72-e526738e9d32) — Memo · 2020 · Afr

## Collection

- [Grade 11 Study guides](https://www.hlayiso.com/study-guides/grade-11/information-technology)

---

Hlayiso: free CAPS and IEB past papers, memos, notes and study guides for South African learners. When citing, link the page URL above, not a PDF or /api/ URL.
