Skip to main content
main-content

Über dieses Buch

Guide to this Book My main objective is to teach programming in Pascal to people in the hard sciences and technology, who don't have much patience with the standard textbooks with their lengthy, pedantic approach, and their many examples of no interest to scientists and engineers. Another objective is to present many both interesting and useful algorithms and programs. A secondary objective is to explain how to cope with various features of the PC hardware. Pascal really is a wonderful programming language. It is easy to learn and to remember, and it has unrivalled clarity. You get serious results in short order. How should you read this book? Maybe backwards is the answer. If you are just starting with the Borland Pascal package, you must begin with Appendix 1, The Borland Pascal Package. If you are a Pascal user already, still you should skim over Appendix 1. Appendix 2, On Programming, has material on saving programming time and on debugging that might be useful for reference. Chapter 1, Introduction to Pascal, will hardly be read by the experienced Pascal programmer (unless he or she has not used units). Chapter 2, Programming Basics, begins to sample deeper waters, and I hope everyone will find something interesting there. Chapter 3, Files, Records, Pointers, is the final chapter to concentrate on the Pascal programming language; the remaining chapters concentrate on various areas of application.

Inhaltsverzeichnis

Frontmatter

1. Chapter 1 Introduction to Pascal

Abstract
The Pascal Language, in the Borland Pascal dialect that we shall use, consists of about 70 reserved words and symbols.
Harley Flanders

2. Chapter 2 Programming Basics

Abstract
Our subroutines so far have been of type function; these subroutines have a result, always an integer type or a real type (but there are limited other possible results). Type procedure subroutines can do all kinds of action, including computing one or more results. The following short program introduces the syntax of procedure, and also introduces array types.
Harley Flanders

3. Chapter 3 Advanced Programming

Abstract
Let us summarize what we know about a file of type Text. It contains a sequence of strings, each terminated by a carriage return CR = #13 and a line feed LF = #10, also possibly by a form feed FF = #12. We declare a variable my_text to be of type text by
var my_text: Text;
Harley Flanders

4. Chapter 4 DOS and BIOS

Abstract
The DOS unit provides many procedures for direct access to various device drivers, particularly disk drives. We used one of these earlier, “GetTime”, to read the system clock. Now we are going to look at some of the procedures for handling disk directories and files.
Harley Flanders

5. Chapter 5 Graphics

Abstract
The Graph unit in Borland Pascal offers a great variety of procedures for dealing with the graphics screen. In this section we’ll illustrate some of them, starting with procedures that control how text is written to the graphics screen. The default font is a bit mapped font that does not magnify gracefully. Borland Pascal provides four other “stroked” fonts that do magnify very nicely. The following program demos these, and procedures that govern how text will be placed on the screen:SetTextStyle and SetTextJustify. The font files “*.chr” must be on line for the program to run properly. If a graphics program cannot find a font, it doesn’t crash, but simply uses the default font instead.
Harley Flanders

6. Chapter 6 Recursive Algorithms

Abstract
Recursion is the heart and soul of Pascal. Up to now we have had one or two explicit uses of recursion in our programs. Now we go at it seriously.
Harley Flanders

7. Chapter 7 More Algorithms

Abstract
We begin this chapter with a fresh look at recursive curves—from an entirely different viewpoint. The instructions for drawing a curve can be in the form of a string. For instance the basic Z shape can be written “LL+L+LL-L-LL”, where L means “line segment”, + means turn forward, means turn backward. The idea, called “string rewriting system”, of using a string of characters to represent a recursive graphics figure was worked out by P. Prusinkiewicz, based on earlier work on modeling organism growth. See Saupe, D, Appendix C in Peitgen H-O, et al, Fractal Images, Springer-Verlag, 1988.
Harley Flanders

8. Chapter 8 Discrete Mathematics

Abstract
Elementary number theory offers many opportunities to experiment, look for patterns, and test conjectures, often requiring only fairly simple programs. In this section we look at some easy examples.
Harley Flanders

9. Chapter 9 Applications to Mathematical Analysis

Abstract
One of the limitations of floating point arithmetic is computer roundoff error. It is measured by a number called unit roundoff error (URE), which is defined as the least positive real number u such that the computer cannot distinguish between 1.0+u and 1.0. Actually, this number is software dependent, and as you will surely test, with Pascal it is different for different real types. The following program is one approach to measuring URE. Its first approximation to u is the first negative power of 10 that doesn’t change 1.0 when added to it. Its next approximation to u is a multiple of that, so the result is the first significant decimal digit of the true u. Then it goes for two more decimal digits, which is really close enough.
Harley Flanders

Backmatter

Weitere Informationen