Mastering Pascal

Preface

Pascal is one of the most widely used PC-based programming languages. It is also one of the best programming languages to teach good software development techniques.

Author:
Dr W.Buchanan,
Napier University,
Edinburgh.

Downloads:
Complete code
Port statement
Using Writeln/readln

Introduction to Pascal and Delphi.
This book provides an introduction to programming with Pascal and extends this to show how Borland Delphi, which uses Pascal, is used to develop Microsoft Windows programs.

Why use Pascal/Delphi?
After many years of teaching software development to undergraduates I have found that C and C++ suffer from several pitfalls, especially in parame-ter passing, pointers and the lack of strong data type checking. These areas may provide flexibility for experienced programmers, but for novices they add to the complexity of the program. I have also been involved with extensive consultancy work and book writ-ing over the years and I have used C, C++ (Borland C++ and Visual C++), HTML/JavaScript, Java, Visual Basic, Turbo Pascal and Borland Delphi. From this, I can say, without doubt, that Delphi is the easiest and most power-ful development system I have found. It provides a great deal of flexibility in that it doesn't try to write all the code for the programmer, and basically it provides a framework for the user to add code to

Real-life Applications.
The best way to learn a programming language is to write real applications. For this reason the book includes many real-life applications. Chapters 13 to 20 cover some practical applications, such as: software interrupts, hardware interrupts, graphics, date and time, system commands, RS-232 and parallel ports. The book thus covers three main areas:

Pascal programming (Chapters 1 to 12).
Pascal applications (Chapters 13 to 20).
Delphi programming (Chapters 21 to 26).

   

 

Contents

Introduction
Input/Output
If Statement
Case Statement
For Loop
While/Repeat Loops
Functions
Procedures
Arrays
Strings
File I/O
Records
Graphics
Software Interrupts
Interfacing
RS-232
Parallel Port
Hardware Interrupts
Date and Time
System Commands
Introduction to Delphi
Delphi Input/Output
Delphi Forms
Delphi Menus and Dialogs
Delphi Events
Delphi Graphics
Appendix A - Turbo Pascal Reference
Appendix B - ASCII
Appendix C - Bits, Bytes and Operators

WinCRT32 

Note: WinCRT32 isn't support in the standard form of Delphi 2 and 3. To use the WinCrt32 unit go the Zielglersoft page and download it from there. There is also an excellent convertor for Turbo Pascal to Delphi. If in doubt, email me

Replacing PORT statements

The PORT command has disappeared from Delphi 3. This a real shame, but here is code which does the equivalent. The two routines are ReadPort() and WritePort().

unit DPort;
interface

function  ReadPort(port:word):byte;
procedure WritePort(data:byte; Port:word);

implementation
function ReadPort(port:word):byte;
 begin
   asm
     mov  dx, port
     cli
     in   al, dx  {read}
     out  dx, al  {..rewrite since some ports reset on 'reads'}
     sti
     mov  Result,al
   end;
 end;

 procedure WritePort(data:byte; Port:word);
 begin
   asm
     mov  dx, port
     cli
     mov  al, data
     out  dx, al       {..write}
     sti
   end;
 end;
end.

Dport.PAS

Dport.DCU

Replacement for WinCrt

Delphi 2 and later

In order to use a console window (to use writeln and readln), the Generate console application checkbox on the Linker page of the Project|Options dialog must be checked.

Delphi 1

Programs which use writeln/readln require that the WinCrt unit is added in the uses list.

 
   

Send comments

Please complete the following details:

Your name (Surname, First name):

E-mail:


Please add you comments:

 

Contacts

S.Tipple, Editor, Palgrave. E-mail: s.tipple@palgrave.com
W.Buchanan, Series Editor, Computing and IT. E-mail: w.buchanan@napier.ac.uk

RECOMMENDED READING AT AN AFFORDABLE PRICE!

Paperback - 272 pages (July 2001 )
Palgrave, formerly Macmillan Press; ISBN: 0333730070