Start Programming Using Object Pascal by Motaz Abdel Azeem - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Chapter One

Language Basics

Our First Application...............................................................................................................................10

Other examples........................................................................................................................................12

Variables..................................................................................................................................................14

Sub types..................................................................................................................................................19

Conditional Branching.............................................................................................................................20

The If condition........................................................................................................................................20

AirConditioner program:........................................................................................................................20

Weight program........................................................................................................................................22

Case .. of statement..................................................................................................................................25

Restaurant program.................................................................................................................................25

Restaurant program using If condition....................................................................................................26

Students' Grades program........................................................................................................................27

Keyboard program...................................................................................................................................27

Loops........................................................................................................................................................29

For loop....................................................................................................................................................29

Multiplication Table using for loop.........................................................................................................30

Factorial program....................................................................................................................................31

Repeat Until loop.....................................................................................................................................32

Restaurant program using Repeat loop...................................................................................................32

While loop................................................................................................................................................34

Factorial program using while loop........................................................................................................34

Strings......................................................................................................................................................36

Copy function...........................................................................................................................................39

Insert procedure.......................................................................................................................................40

Delete procedure......................................................................................................................................41

Trim function............................................................................................................................................41

StringReplace function.............................................................................................................................42

Arrays.......................................................................................................................................................44

Records....................................................................................................................................................47

Files.........................................................................................................................................................49

Text files...................................................................................................................................................50

Reading text file program........................................................................................................................50

Creating and writing into text file............................................................................................................52

Appending to a text file............................................................................................................................55

Add to text file program...........................................................................................................................55

Random access files.................................................................................................................................56

Typed files................................................................................................................................................56

Marks program........................................................................................................................................56

Reading student marks.............................................................................................................................57

Appending student marks program..........................................................................................................58

Create and append student marks program.............................................................................................59

Cars database program...........................................................................................................................60

File copying.............................................................................................................................................62

Copy files using file of byte......................................................................................................................62

Untyped files............................................................................................................................................64

Copy files using untyped files program...................................................................................................64

Display file contents program..................................................................................................................66

Date and Time..........................................................................................................................................68

Date/time comparison..............................................................................................................................70

News recorder program............................................................................................................................71

Constants..................................................................................................................................................73

Fuel Consumption program.....................................................................................................................73

Ordinal types............................................................................................................................................75

Sets...........................................................................................................................................................77

Exception handling..................................................................................................................................79

Try except statement.................................................................................................................................79

Try finally.................................................................................................................................................80

Raise an exception..................................................................................................................................81