Programming in PASCAL Module 01 - Introduction by daro007


									Programming in Pascal - 1

Programming in PASCAL                      Module 1- Introduction

Third Generation Languages
Imperative Languages
Pascal dialects
Why not English?
Creating a computer program
Requirements for this course

Pascal is a computer programming language that was invented by Niklaus Wirth in the
early 1970s. The main purpose of the language was to be a tool for teaching structured
programming. It has become a popular general purpose programming language used for
both learning the process of programming and for real world applications. In this
programming course you will learn how to program using the Pascal language. This will
provide you with skills that you can transfer to other programming languages like C and
Visual Basic.

Third Generation Languages
Pascal is an example of a third generation language. 3GLs were developed to make it
easier and faster to write computer programs. 3GLs are also known as high level
languages. Such languages relate directly to the way in which humans solve problems.
They use commands and constructs that relate to the processes involved in a problem
rather than to any particular computer the program might have to run on. As such they are
said to be problem oriented rather than machine oriented.

Q 1. Describe the different generations of programming languages:
1st generation – Machine language

Programming in Pascal - 1

2nd generation – Assembly language

3rd generation – High Level language

Imperative (Procedural) Programming Languages
Another way of classifying programming languages is into imperative and declarative
languages. This reflects the idea that humans possess two different kinds of knowledge:
     Declarative knowledge – facts about people, objects and events and how they relate
       to each other;
     Procedural knowledge – how to do things.

Pascal is an example of a imperative or procedural language which we can use to tell the
computer how to perform a task. For example getting the computer to print out a list of
names involves telling the computer how to do this by giving it a series of step-by-step
instructions. We can do this using the Pascal language.

Q 2. Give some other examples of imperative languages:

Programming in Pascal - 1

Q 3. Give an example of a declarative language:

Why not English?
Why not program in English? English has a complex set of rules governing the syntax (the
way we put words and sentences together) and the semantics (the way we derive meaning
from the words and sentences) of the language. This makes it virtually impossible to
define precisely the language so that it can be translated into the binary codes that the
computer can process. Computer languages, on the other hand, are much simpler and can
be defined precisely.

Having said that, the development of artificial intelligence systems is bringing closer the
day when computers can be controlled and programmed using plain English.

Pascal dialects
Like any spoken language computer languages also have dialects. In 1983 the IEEE and
the ANSI agreed a standard definition of the Pascal language. Over the years, however,
different versions of the language have been developed in order to introduce features not
present in the standard. There are now a number of versions of Pascal available including
UCSD Pascal, Turbo Pascal, Free Pascal and Delphi. The popularity of Turbo Pascal and,
more recently, Delphi has made them de facto standards. Free Pascal is based very much
on standard Pascal and Turbo Pascal but has the advantage of being free to the user.

This course is based on Turbo Pascal for which you will use either Delphi or Free Pascal
for development of your programs.

Creating a Computer Program
The process of creating an executable program that will run on your computer is made up
of a small number of discrete steps:
    1. Create and edit the source code file. This file is a text file containing the program
       written in the high level language, Pascal in our case. The file is created and edited
       using a text editor such as Notepad. MS Word could also be used provided that the
       file is saved as a text file rather than a document file. In this manner the file is
       saved without any special formatting codes that would interfere with the
       compilation stage.
    2. Compile the source code to create an object code file. A program called a compiler
       is used to covert the program in Pascal into the binary code that the machine can
       eventually execute. The output is called an object code file. Each language will
       have its own compiler and each computer processor will also need its own compiler
       for each language.
    3. Link the object code file to any library files referred to in the original program.
       Library files are pre-compiled object code files that contain common procedures
       and functions of the language. You can create your own library files of procedures
       and functions that you have written yourself for your own projects. The use of

Programming in Pascal - 1

       libraries saves you having to reinvent code for common tasks. The output of the
       linking process is the executable file.
    4. Load and execute the program executable file.

                                       Input source code

                                                                         Error list


        Library                              Linker


                                          Load & run
                                        executable code

                            System flow diagram for the creation of an
                                      executable program

Programming in Pascal - 1

Modern programming systems such as Turbo Pascal and Delphi combine the processes of
editing, compiling, linking and execution into one program called an IDE or Integrated
Development Environment. This makes the management of the processes and the settings
for a project much easier.

Requirements for this course
The minimum requirement is a computer system that has an editor and a Turbo Pascal
compatible compiler installed.

In school you will be using Delphi to create programs that run in a console window (text
input and output only). To use Delphi in this manner you will also need a library code
module to provide the text based interface. This is available from: Download the Winn32CRT version 2.10,
unzip and install the version suitable for your version of Delphi. The file win32crt.dcu
should be placed in the same folder as all your other dcu files that were installed with

Delphi is a full featured programming system for creating Windows applications using all
the GUI features. However we will be concentrating on simple text based input and output
in order to focus on the concepts of programming.

Delphi is often available on computer magazine cover disks.

An alternative to Delphi is Free Pascal which is downloadable from the internet. Go to .


To top