# MacPascal Programming 1985 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-307390541e4c3e1babd4ae007c19e673bf31fbc46b464d3e5fa3ed4f698f95e1)

Transcribed text:

1891

MacPascal Programming

Drew Berentes

Image description: A young man with reddish-blond hair in a light blue short-sleeve shirt sits in profile at a desk using a beige Macintosh computer with a mouse, keyboard, and window with greenery behind him, under a black banner title on the cover.

Reading notes: The number '1891' in the top-left corner is small and its meaning is unclear; it is transcribed as printed. The author name 'Drew Berentes' is legible but the spelling should be verified against the book's credits. Text on the computer screen is too small to read and is not transcribed.

Printed product names: MacPascal

Printed dates: 1891

Languages: English

[Original Image 1](https://www.vintageapple.net/files/fbd882f1cefd076bf9e70c56744bcb9ae64376bbcc848656087b499f6abbe85a/28d672928ed23d6ba0de5ad0.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-27aa16af83aa6f7719ea3027b9070ec2f18325d662cc12aaac251874bc6c376b)

MacPascal Programming

Transcribed text:

1891
MacPascal
Programming
Drew Berentes

Image description: A book cover with a black banner bearing the gold title MacPascal Programming and author name Drew Berentes, showing a young man with reddish-brown hair in a light blue shirt working at a beige Macintosh computer and keyboard beside a window with foliage.

Reading notes: The number 1891 in the top-left corner is printed small and may be a catalog or series number rather than a date. The screen text on the computer monitor is too small to transcribe and was not included.

Printed product names: MacPascal

Printed dates: 1891

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-78bad84e00ce4cc34bc984a6008fb23e71b953ce7438582a2dc94b9ebcc0c9f1)

Image description: The image is a completely blank white page with no visible artwork, layout elements, or text.

Reading notes: No visible text or graphics appear anywhere on the page, so the transcript is empty.

[Original PDF page 2](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-0ba9bd759643ac83427500e8f188bf231caa0098be69b27ee96df2b794a46c73)

MacPascal programming

Transcribed text:

For Woody
Macintosh™   is a trademark licensed to   Apple   Computer,   Inc.
Apple®   ,   Macintosh™   Pascal,   and   MacPaint™   are trademarks of   Apple   Computer,   Inc.
FIRST   EDITION
FIRST   PRINTING
Copyright© 1985 by TAB   BOOKS   Inc.
Printed in the   United   States of America
Reproduction or publication of the content in any manner, without express
permission of the publisher, is prohibited. No   liability   is assumed with respect to
the use of the information herein.
Library of Congress   Cataloging   in   Publication   Data
Berentes, Drew.
MacPascal   programming.
Includes   index.
1. Macintosh (Computer)-Programming. 2. PASCAL
(Computer program   language)   I.   Title.
QA76.8.M3B47   1985   001.64'2   85-9740
ISBN   ~306-0891-5
ISBN   0-8306-1891-0   (pbk.)
Cover photograph by the   Ziegler   Photography Studio of Waynesboro, PA.

Reading notes: Some tokens such as ISBN '~306-0891-5' and '001.64'2' may be OCR artifacts and are uncertain

Printed product names: Macintosh · Apple · Apple Computer, Inc. · MacPascal

Printed dates: 1985 · 85-9740

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-1d2917d5ef95aac6e25cca1edcc2ae9c89ae477b2ce8bafcd0d328bc80c06b5a)

Transcribed text:

Contents
Acknowledgments   vi
Introduction   vii
1   Introducing Macintosh Pascal:   Pascal   Procedure   Statements   1
Topics Covered in This Chapter   1
Things You   Will   Need   2
Before You Begin   2
Editing Text on the Macintosh   3
Some Programming Concepts   7
A First   Pascal   Statement:   Introducing   the   WRITELN   Procedure   8
Errors in   Pascal   Statements   12
More about Printing Text   13
Working with Numbers   16
A First Look at Graphics and Music   21
Ending a   Pascal   Session   22
Your   Pascal   Vocabulary   22
2   Writing and Running   Pascal   Programs
Topics Covered in This Chapter   24
Entering and Running a   Pascal   Program   24
Saving   and Retrieving Programs   27
The Anatomy of a   Pascal   Program   30
Characteristics of the Macintosh   Pascal   Editor   32
Printing Your Programs   35
Your   Pascal   Vocabulary   ~
3   Simple   Data Types and Variables
Topics Covered in This Chapter   38
Simple   Pascal   Data Types   38
The Types Char and String-The Type   Boolean
Introducing   Variables   41
24
38
-, ....

Reading notes: Table of contents page numbers and some chapter entries contain stray spacing or ellipsis marks such as '-, ....' and '~'.

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-851d21c3fbb1c5a0fe2c0d0b003696d7e08e82342bf245676df5cb8bfba16fed)

Transcribed text:

\_
Identifiers   and Reserved Words   43
Assigning Values from the Keyboard: The READLN Statement   44
A Closer Look at Type Matching   46
Your Pascal Vocabulary   48
4   Control   Statements Part 1: The   FOR   Statement
Topics Covered in This Chapter   49
The   FOR   Statement   49
Demonstration Programs with   FOR   Loops   54
A   FOR   Statement Bug   59
Your Pascal Vocabulary   60
49
5   Control   Statements Part 2:   WHILE   and REPEAT Statements   61
Topics Covered in This Chapter   61
What   FOR   Statements Can't Do   61
The   WHILE   Statement   63
The REPEAT.. UNTIL   Statement   fn
Comparing   WHILE   and REPEAT Loops   73
Your Pascal Vocabulary   75
6   Control   Statements Part 3: Branching with   IF • • THEN and   CASE   77
Boolean Expressions   77
The   IF..THEN   Statement   80
A Nested   IF   Statement Bug   91
The CASE Statement   94
Your Pascal Vocabulary   98
7   Defining Procedures and Functions
Topics Covered in This Chapter   100
Drawing a Rotated Square   101
Defining Procedures   106
Defining Pascal Functions   110
Moving Data   In   and   Out   of Procedures and Functions   118
The Scopes of Program Variables-The   Use   of Parameters
Your Pascal Vocabulary   124
8   Data   "fypes:   Built-In   and User-Defined
Topics Covered in This Chapter   126
Real Data   "fypes   126
Integer   Data Types   130
Ordinal Types:   Integer,   Char, and Boolean   130
Enumerated Types   131
Subranges of Types   133
Your Pascal Vocabulary   135
9   Structured   "fypes:   Arrays
Topics Covered in This Chapter   136
Single-Dimension Arrays   137
Graphic Display of the Dice Program Results   140
Changing the Pen Pattern   145
Multi-Dimension Arrays   147
A Gradebook Program   149
Your Pascal Vocabulary   156
10   Structured Types: Records
Topics Covered in This Chapter   159
An   Introduction   to Pascal Records   159
Records and MacPascal Graphics   164
100
126
136
158

Reading notes: Source appears to be a table of contents with garbled characters (e.g., 'fn', 'fypes') and inconsistent OCR spacing.

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-43c569794f859f17aa893f6bc813eab584122dda2b2afef8c572614c2150cc77)

Improving a Drawing Program

Transcribed text:

Improving   a Drawing Program   166
Variant Records   170
Predefined Variant Record Types in   MacPascal   174
Your   Pascal   Vocabulary   176
11   Strings
Topics Covered in This Chapter   178
The Characteristics of Strings   178
Building   Strings   180
Taking Strings Apart   181
Displaying   Text in the Drawing Window   185
Mixing Text with Graphics   190
Your   Pascal   Vocabulary   192
12   Structured Types:   Files
Topics Covered in This Chapter   194
An   Introduction   to   Files   195
How   Files   Work   196
Modifying the Contents of   Files   198
Working with Random-Access   Files   200
A   Simple   Inventory   Program   201
Text   Files   209
The   Use   of the   INPUT   and   OUTPUT   Files   214
Input   and   Output   with Macintosh Devices   216
Manipulating   the   File   Buffer   220
Your   Pascal   Vocabulary   221
13   Searching,   Inserting,   and Shuffling
Topics Covered in This Chapter   224
Searching for Data in Ordered Arrays:   Sequential   Search   224
A Binary   Search   Strategy   227
Binary Searches in   Files   229
Inserting   Data into   Ordered   Arrays   230
Improving   Insertion   with a Binary   Search   234
Inserting   Data   Into   Files   236
Shuffling   240
Your   Pascal   Vocabulary   241
14   Sorting
Topics Covered   In   This Chapter   244
Bubblesort   244
Quicksort   249
15   An   Improved   Inventory   Program
The   Inventory   Program   260
The   Declaration   Part   269
The Main Program   269
The Functions and Procedures   270
The Function   REALINPUT-The   Procedure   Display   ITEM-The   Function   LOOKUP-The   Procedure
INSERT-The   Procedure ADD-The Procedure   BUY-The   Procedure DELETE-The Procedure
FIND-The   Procedures   REPRICE   and SELL-The Procedure   lOTALS-The   Procedure PACK
Conclusion   273
Appendix   The Macintosh Pascal Character   Set
The Program   274
Printable   Characters in Macintosh   Pascal   275
Index
178
194
224
244
260
274
276

Reading notes: Table of contents entries include page numbers that are not clearly associated with each heading. Some words are split with inconsistent spacing (e.g., 'Your   Pascal   Vocabulary'), so exact spacing may vary.

Printed product names: MacPascal

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-102ae0e11b57c5943a797899541cec5a22515bfc616d74ad5657e7a6dc9fb822)

Transcribed text:

Acknowledgments
This book could not have been written without the support of several persons.
Kevin Jones at Apple Computer graciously supported my efforts, making software and manuals
available.
Kevin Burton at TAB   BOOKS   Inc. provided constant support during the genesis of this book.
I hope that I have not driven him crazy with my many questions and problems. He has dealt with
them all promptly, effectively, and sympathetically. I look forward to working with Kevin in the future.
To a special, seemingly unflappable person, to Marilyn Johnson at TAB my deepest thanks. Her
efforts in editing my last book went above and beyond the call of duty. I can only imagine the frustra-
tion of dealing with a nervous and demanding author under the necessity of meeting a production
deadline, but through all of the confusion and pressure, Marilyn was nothing but diligent and helpful.
Finally, to Lydia Berentes, my gratitude for her hours spent in proofreading and for her loving
support. No one knows how much work goes into a book as well as the person who lives with the
author, and no one must have greater patience.
vi

Reading notes: Page number 'vi' at the end is a printed marker and may not be part of the body text.

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-466c7dd17b18f1eb14d71eff0fbdefd649aaa04675ffb719d78483114805fa0c)

Transcribed text:

Introduction
For me computer programming is one of the most fascinating   activi~ies   that is available in the modern
world. It is never ending in its complexity-one can never learn everything about it-but it is almost
unlimited in the sense of accomplishment it can inspire. Through programming we learn an approach
to problem solving that has broad applications in many other areas of our lives. Through program-
ming we can create tools that solve complex problems, games of great challenge, and graphic displays
of complex beauty.
Programming is a powerful incentive to learning. Mathematical concepts that may have bored you
in the past take on new vitality when they are seen working in a program. And yet, extensive knowl-
edge of mathematics is in no way a prerequisite   to   programming. The simple fact is that the desire
to do something is a strong motivation towards learning how to do it.   If   you want to animate a figure
in a computer game, you will be inclined to learn the mathematics and techniques of simulating mo-
tion. And you will have fun along the way.
Mathematics is not the only area in which this phenomenon takes place.   If   you want to write a
program that creates poetry, you must teach the computer to construct proper sentences. The rules
of grammar that seem abstract and dull in school take on new meaning since you need them to solve
your problem.   If   you need an accounting program, you must learn accounting procedures.
Pascal is a particularly suitable language with which you can learn programming. Most modern
programming concepts are available in Pascal, in sharp contrast to   BASIC,   perhaps the most popular
beginning language. Although it is easy   to   get started in   BASIC,   things become much more complex
as programs grow in size. Pascal programs, by contrast, expand gracefully. You will find that the largest
program in this book is little more difficult to understand than many of the smaller ones.
The concepts you learn with Pascal are applicable in almost any programing environment.   Once
vii

Reading notes: Possible OCR artifacts such as 'activi~ies' and 'programing' in the copy; spelling preserved as printed. Heading is absent from the supplied copy, so headline is null.

Printed product names: Pascal · BASIC

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-1a5697473768d4572c4877a6441d2b64ed04cbe803f7cecc478654acd019a42f)

Transcribed text:

thoroughly grounded in Pascal you should be able to move readily to other languages. Also, Pascal
is more consistent than   BASIC   when moving from one computer to another. Regrettably, different
versions of Pascal abound, but the uniformity of Pascal is still fairly high.
I have wanted to write a book about Pascal for some time. My particular bias in writing computer
texts is to provide strong support for beginning programmers who are teaching themselves the art.
In this respect, Macintosh Pascal was worth waiting for. MacPascal is by far the most supportive   en-
vironment I have found for learning Pascal. In fact, it is one of the best for any implementation of
any language.   It   provides numerous programmers tools unavailable in any other Pascal package of
which I am aware, and it has allowed me to introduce you to Pascal in small, manageable steps. Thanks
to   the special features of MacPascal, you will be able   to   do interesting things in Pascal in the first chapter.
MacPascal takes full advantage of Macintosh user interface, which is presently the best in the
microcomputer business. Much less time is required to learn the essentials of Macintosh operation
than to learn them for any other computer I can think of.
This book has two major objectives:
•   To help you teach yourself the basics of Pascal programming
•   To introduce you in detail to the use of Macintosh Pascal.
Many activities that will get you working with your Mac, not just reading about it, are included. Through
these activities you will use most of the MacPascal programmer's support tools as well as enough
features of Pascal to enable you to create interesting programs of many different sorts.   If   you do
everything I suggest, I am sure that you will learn a lot from the book.
The going will not always be easy. I will not issue idle promises about this book making   program-
ming a task to be learned with elementary ease.   If   programming could be made easy, would we need
all of the introductory programming texts that have flooded the book market in recent years? As I
noted earlier, the complexity of computer programming continues without end. And, unfortunately,
many of the mental skills programming requires must be learned through hard work and practice.
But nothing worthwhile is learned without some work. That is why athletes, musicians, and   program-
mers must work hard to become great.
However, programming is also a skill that anyone can learn. Elementary school children have become
competent programmers. I firmly believe that anyone can learn to program and can find reward in
the process.
With those remarks, I invite you to embark on a programming adventure. Above all, have fun.
In   the process, you may be amazed at how much you will learn.
viii

Reading notes: Numerous stray spaces and line breaks in the extracted copy may affect reading order. Printed page number 'viii' appears at the end of the source text.

Printed product names: Macintosh Pascal · MacPascal · Pascal · BASIC

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-9ac9def10b0476fe1dc45d1fa8e4b4a2087fde1ec96328459e7474408d0a5f9b)

Introducing Macintosh Pascal: Pascal Procedure Statements

Transcribed text:

Chapter 1
§0   Instant
LJ&ij~J
penpet(ltgray);
paint.ove1 (60.   5 . 195,   200) ;
pen pet (dkgray);
pensize (   10 ,   3) :
frameovel(30,   10,   120,   190);
invert.rect. (50.   40 ,   160,   1 BO);
Introducing   Macintosh   Pascal:
Pascal   Procedure Statements
In this first chapter we will jump right in and look at Pascal procedure statements. These are the
simplest structures in Pascal, and every program is built by carefully combining them to perform com-
plex tasks.
In the process of examining procedure statements, we will take a first look at the Macintosh Pascal
programming environment, which is extremely powerful and supportive. Before we can begin, howev-
er, I have to make sure that you have acquired some basic skills in using the Macintosh.
TOPICS   COVERED   IN   THIS   CHAPTER
•   Selecting options from the Macintosh pulldown menus
•   Typing
•   Selecting text for replacement
•   Starting up Macintosh Pascal
•   Using the MacPascal Instant, Text, and Drawing windows
•   Executing procedure statements in the Instant window
•   Using proper syntax for WRITELN statements
•   String   expressions
•   Using semicolons to separate Pascal statements
•   Numeric expressions and operations
•   Using field parameters in WRITELN statements
•   Pascal functions
•   •   Generating a musical note
•   Drawing several MacPascal graphics shapes
•   Ending a Macintosh Pascal session
1

Reading notes: Code fragment at top of extracted text (pen/frame/invert.rect calls) has garbled characters and uncertain reading order.

Printed product names: Macintosh · Macintosh Pascal · MacPascal

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/1#scan-d7c8abcc9dd03e87239187b4c25bb25ad9c0cb8317058bbe7f8e0d77d01a9800)

THINGS YOU WILL NEED

Transcribed text:

THINGS   YOU   WILL   NEED
You can do everything in this book using only these four items:
•   A Macintosh computer (128K or 512K)
•   A Macintosh Pascal program disk,
•   One   or more blank storage disks
•   This book.
Two additional items may be helpful.   An   Imagewriter printer will allow you to print out programs
and other items associated with your Pascal activities.   It   is often easier to work with large programs
if they are printed out.
An   auxiliary disk drive is a very convenient thing to have because it makes it much easier to copy
things between disks. The Pascal disk has very little free space on it. You will eventually find yourself
needing to store programs on other disks. This can be done using only the disk drive built into your
Mac, but copying is much easier with two disk drives.
BEFORE   YOU   BEGIN
After this section, I am going to assume that you know a thing or two about using the Macintosh.
If   you are at all experienced with the Mac, you probably know everything you need to know to keep
up with me.
If   you are a new user, however, you should spend some time with your Macintosh manual. It won't
take you long to read the sections I suggest. The lessons are excellently presented and can be read
very quickly. While you do not have to be familiar with every detail about Macintosh operation, the
more you know the better.
Before you continue, I recommend that you go through the following chapters in your Macintosh
reference:
1. Leaming Macintosh
2. Finding   Out   More About Macintosh
3. Using the Finder
You should be sure that you become familiar with these topics:
•   Starting up the Macintosh
•   Mouse operations: pointing, clicking, double clicking, dragging, etc.
•   Selecting and manipulating icons
•   Using the pulldown menus
•   Opening   windows
•   Using scroll bars in windows
•   Moving and changing the size of windows
•   Starting Macintosh applications
•   Using folders
•   Copying, renaming, moving, and removing documents, folders, and applications.
Don't read for detail right now. Just go for the main features. I am going to prompt you a bit dur-
2

Reading notes: Page header and page number '2' at the end are partially cut off, so the source ends mid-sentence ('prompt you a bit dur-').

Printed product names: Macintosh computer · Macintosh Pascal program disk · Imagewriter printer

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/eac00bde17049c163b2251d7154809c93a21c13406d9b60e78075567e3a9438b/MacPascal_Programming_1985.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-macpascal-programming-1985-545997/2.md)
