← Introduction to Macintosh Pascal

Introduction to Macintosh Pascal

From the originals

23 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

PDF page 12

Introduction Setting Up For This Book This section assumes that you are familiar with the basic operation of your Macintosh. You should know: • How to start your Macintosh • How to use menus and choose menu commands • How to use the mouse and mouse button • How to select, open, and drag icons • How to select text • How to use folders If you don't know how to do these, read the Macintosh manual, or use the guided tour disk that came with your Macintosh. Preparing For This Book The Macintosh Pascal disk comes with many useful and interesting programs and much useful information on it. If you do not have an external disk drive, you need to clear some of that information off the Macintosh Pascal disk to make room for the programs created in this book. (If you have an external disk drive, you can skip this section; just store this book's programs on another disk.) If you have only one (internal) disk drive, follow these directions to make room on the Macintosh Pascal disk for the programs created in this book: 1. If your Mac is on, eject any disk that is in the drive and turn the Mac off. .2. Tuke one of the disks that comes in your Macintosh Pascal package and put that in the disk drive. (There should be two identical disks in the package. The second is there in case something happens to the first.) 3. Put the disk in the drive, and turn your Mac on. After a few minutes, you should see the Mac's desktop, as shown in Figure Intro-1.

Reading notes: Possible OCR artifacts: 'Tuke' may be 'Take' and '.2.' may be a stray character in the numbered list.

Printed product names
Macintosh Pascal · Macintosh
Languages
English
PDF page 13

Introduction to Macintosh Pascal

Introduction to Macintosh Pascal r s File Edit Uiew Special Figure Intro-1 Initial Desktop 4. Select the Pascal icon, and choose Open from the File menu. The icon should open, so that the screen now looks like Figure Intro-2. r s File Edit Uiew Special Pascal El ~ CJ CJ CJ Open Me Macintosh Pascal Tools Information Demos Figure Intro-2 Open Pascal Disk

Reading notes: Garbled characters in menu bar text (e.g., 'r s File Edit Uiew Special' with 'Uiew' likely 'View') Icon label text in Figure Intro-2 is partially corrupted

Printed product names
Macintosh Pascal
Languages
English
PDF page 14

Introduction 5. Choose the New Folder command from the File menu to create a new folder. A new folder saying "Empty Folder" under it appears. ·~~~~~~~~~- N -o ~ te _s ~~~~~~~~~~~~~~~~~~ If you are using a finder earlier than Finder 4.1, there is no New Folder command. Instead, you create a new empty folder by duplicating the single Empty Folder found on each disk. 6. Change the name of the folder from "Empty Folder" to "Pascal Info Folder". It should now appear as shown in Figure Intro-3 . • Pascal Info Folder Figure Intro-3 New Folder 7. Drag the following icons into that folder: Open Me Tuols Information Demos 8. Click the mouse on the Pascal disk icon image. Use the mouse to pull down the File menu and choose Eject. The Pascal disk pops out of the drive. 9. Insert your blank disk. If you've never used the disk before, a box appears on the screen that asks you if you want to eject the disk or initialize it. Click Initialize. If it isn't a new disk, throw everything that is on it into the Trash.

Reading notes: Possible typo 'Tuols' in icon name list OCR spacing irregularities in 'Introduction' and 'N o te s' section heading

Printed product names
Pascal Info Folder · Finder 4.1 · Open Me · Tuols · Information · Demos
Languages
English
PDF page 15

Introduction to Macintosh Pascal 10. After a minute or two, you are asked for a name for the new disk. Type: Pascal Info If this isn't a new disk, change its name to "Pascal Infd' by selecting the old name and typing. You may also want to throw everything on the disk into the Trash or· select the new disk (not the Macintosh Pascal disk) and choose the Erase command. Make sure there isn't anything important on the disk before you do that. Click the mouse in the OK box. After a few seconds, the desktop shows again, with your blank disk shown underneath the Pascal disk. The blank disk is labeled "Pascal Info:' 11. Drag the Pascal Info Folder icon to the Pascal Info disk icon, and let go. It should disappear. The Macintosh displays a box showing the number of files that need to be copied, and it asks you to exchange the disks several times. When it is done, you've copied everything in the Pascal Info Folder to the Pascal Info disk. 12. If the Pascal disk is not in the Macintosh, eject the Release Info disk, and insert the Pascal disk. 13. Drag the Pascal Info Folder into the Trash. You no longer need it, since you have a copy on your Pascal Info disk. Your Pascal disk should now look like Figure Intro-4. Keep the Pascal Info disk. The information on it is very useful, and the demo programs are fun and well done. There are also three utility programs in the Tuols folder that you may use later.

Reading notes: Quoted disk label 'Pascal Infd' appears to be an OCR or typographic variant of 'Pascal Info' Folder name 'Tuols' may be a misspelling of 'Tools'

Printed product names
Macintosh Pascal · Pascal Info · Trash
Languages
English
PDF page 16

Introduction Figure Intro-4 Pascal Disk Prepared for Use How To Use This Book This book is designed to be used with Macintosh Pascal and your Macintosh. It isn't hard to learn how to program, but programming is something you can only learn by doing. You can't learn how to program without actually programming a computer any more than you can learn to bicycle without riding a bicycle. As you read this book, type the programs from the chapters. The instructions are laid out so that you can type them with a minimum of errors. Be careful while you type, though. Computers are very picky, and every character must be right. (Nothing terrible will happen if you make a mistake, you'll just have to find it and fix it.) Save the programs - they do useful things, and are designed so that you can use them in programs you write later. Also, some of the larger programs are built up chapter to chapter. Feel free to experiment. Modify copies of the programs. The best way to learn to program is to play and explore. The programs in this book provide working frameworks for using your imagination.

Printed product names
Macintosh Pascal · Macintosh
Languages
English
PDF page 17

Introduction to Macintosh Pascal Use the Macintosh Pascal Reference Manual. The Reference Manual fully documents Macintosh Pascal. By the time you've gone through the first half of the Introduction to Macintosh Pascal, you will be comfortable with reading and using the Reference Manual. The second half of this book deal with topics that are more difficult to understand, and acts as an aide for the most difficult parts of the Reference Manual.

Printed product names
Macintosh Pascal · Macintosh Pascal Reference Manual
Languages
English
PDF page 114

Fonts 99 Chapter 4: What Type Through Yonder Window Breaks end; {picked} procedure WriteSample; var h, v : INTEGER; begin repeat unt ii But ton; GetMouse(h, v); MoveTo(h, v); WriteDraw('A rose is a rose '); end; begin {main} stopProgram := FALSE; SetUp(o l dDrawi ngRect, theChoi ces); repeat Pi ckedOne( theChoi ces, whi chBut) ; case which But of 0: Wri teSamp le; 1 : stopProgram :=TRUE; end; until stopProgram; SetDrawi ngRect(o l dDrawi ngRect); end. Figure 4-6 Every character in any book, magazine, or newspaper, or on any computer screen, has been designed by somebody. Generally, an entire set of type, covering every letter, number, and character is designed at once. That set of characters is normally in a single style, so that it provides a pleasing, or at least coherent, appearance. In the world of typography, a font generally has a fixed size and face. On the Macintosh, though, a font is simply a set of type in one style, and the size and face characteristics can change. Figure 4-2 shows some sample fonts.

Reading notes: Source text contains broken spacing and fragmented words, such as 'unt ii But ton' and 'Wri teSamp le', that may be OCR artifacts. Reading order of the Pascal code fragment and the prose passage is uncertain.

Languages
English
PDF page 115

100 Introduction to Macintosh Pascal ~~~~~~~~~~~~ On the Macintosh, the fonts are usually identified by the names of cities. Macintosh Pascal displays programs with the Geneva font. System information, such as menus and window titles, use the Chicago font. Macintosh Pascal, though, does not use the font names. Instead, it uses identifying numbers. "O" identifies the system font. The other integers identify the fonts on that disk. You can add or remove fonts with the Font Mover utility, which you should have on the system disk that came with your Macintosh. Tu change the fonts on the Pascal disk, copy the Font Mover to that disk, and run it. You may have to experiment to find the identification numbers for the fonts you've added. Fonts are set with the QuickDraw TuxtFont procedure. Tu create the Explore Fonts program: 1. Open the Explore Tuxt program if it is not already open. 2. Choose Save As ... from the File menu. 3. 1)'pe "Explore Fonts" as the file name. 4. Click in the Save button. 5. Change the value of NUMBUTS to 10. That line should now be: NUMBUTS = 10; {The number of buttons.} 6. Place an insertion point before the case statement in procedure DrawButtons and type: if (n < 10) then WriteDraw(n-1 :1) else 7. Still in procedure DrawButtons, delete the two lines: case n of 1 : The line: WriteDraw('Stop'); should follow the word else. (Notice there is no semicolon between else and WriteDraw.) 8. Still in procedure DrawButtons, delete: end; {ends case}

Reading notes: OCR errors in several words such as 'Tuxt' and 'Tu' for 'Text' and 'To' Garbled line in step 6 and 'WriteDraw' spacing ambiguous

Languages
English
PDF page 116

Chapter 4: What Type Through Yonder Window Breaks

101 Chapter 4: What Type Through Yonder Window Breaks ~~~~~~~~~~~- (If you didn't type the comment, just remove an end statement and a semicolon from the end of procedure DrawButtons.) Procedure DrawButtons should now look like Figure 4·7. procedure DrawButtons (var theChoices: choices); Yltr n: INTEGER; begin for n := 1 to NUMBUTS do begin SetRect(theChoices[n), BUTLEFT, n * BUTHEIGHT, BUTRIGHT, (n + 1) * BUTHEIGHT); FrameRect( theChoi ces[n)); MoveTo(BUTLEFT +SPACE, (n + 1) * BUTHEIGHT - SPACE); if (n < 10) then Wri teDraw(n - 1 : 1) else Wri teDraw('Stop'); end; {ends for loop} end; {ends DrawButtons} Figure 4·7 The effect of this addition is to print a font number in each button except the last. Stop is printed in the last button. Look at the first line: if (n<10) then The symbol "< " means "less than:• This statement checks the value of the for loop's index variable n. When n is less than 10, the statement following is executed. That statement prints the value of n in the button. When the value of n is equal to 10, "Stop'' is printed in the button. The statement that prints the button numbers needs some explanation. Look at it again: WriteDraw(n-1:1) The first part inside the parentheses, "n-1;• subtracts 1 from the index variable to get the number of the font that will be used when this button is pressed. The second part, ":1;• indicates a minimum field width. The field width tells WriteDraw how many characters to expect. When

Reading notes: Garbled OCR spacing in code listing, e.g. 'theChoi ces' and 'Wri teDraw' Figure reference and inline code fragments may be incompletely reproduced

Languages
English
PDF page 117

102 Introduction to Macintosh Pascal printing INTEGER values, if you specify a minimum field width, the number is printed starting at the current pen position. Additional characters are printed to the right. If you do not give a minimum field width, the number is printed centered a few pixels to the right of the pen position. 9. Place an insertion point before the case statement in the main program and type: if (whichBut>O) and (whichBut<10) then TextFont(whichBut-1) else 10. In the case statement in the main program, change the line: 1 : to: 10: The main program should now look like Figure 4-8. 11. Choose Save from the File menu. begin {main} stopProgram :=FALSE; SetUp(o 1dDrawi ngRect, theChoi ces); repeat PickedOne(theChoices, whichBut); if (whichBut > 0) and (whichBut < 1O) then TextFont(whichBut - 1) else case whi chBut of 0: WriteSamp 1 e; 10: stopProgram := TRUE; end; unt i 1 stopProgram; SetDrawi ngRect(o 1 dDrawi ngRect); end. Figure 4-8

Reading notes: Source text is a programming textbook excerpt with code fragments, not advertising copy. Some code characters appear damaged (e.g., 'O' vs '0', '1O' vs '10', 'Save' line ordering uncertain).

Printed product names
Macintosh Pascal
Languages
English
PDF page 118

103 Chapter 4: What Type Through Yonder Window Breaks ~~~~~~~~~~~~ Faces Run this program. Whenever you click in a button with the mouse, you change the font to the font number indicated. Then, when you click anywhere in the Drawing window, the sample string of text is printed in the current font. Notice that several different font numbers produce the same characters. That is because you do not have nine fonts on the Macintosh Pascal disk, unless you put them there with the Font Mover. When you try to set the font to a number that doesn't exist, the Geneva font is displayed. You can use any of these fonts in any program simply by calling TuxtFont, and giving the number of the font you want to use. Aside from a font's basic style, any font can have a set of characteristics imposed on it. Face characteristics don't change the basic design of the font. They change the appearance of the characters in other ways. The available characteristics are: • Bold. In this style, characters are repeated an appropriate number of times slightly offset, so that they appear darker than normal. • Italic. In this style, the characters are skewed so that they have a distinct slant. • Underline. Tu underline characters, you give the underline characteristic. Then they appear with a line beneath them. • Omilliime. Owtllfume cllDsnrac1iell'a &'IJ?ll)ellD!' wMiln m dlamllc cdmie llil!ldl llnollllcw cemteir : • SllD.11Clow. SllD.11illloweCl cllD.u11cteirs ue Olllltnimi.eCl, &llll.Cl llllso llD.11ve tllD.e 01111tllillll.e tllll.11clke111leCl to tllD.e !bottom. daDll.t. • Condense. When you condense text, the spaces between characters are made smaller by an appropriate amount. The characters themselves are not changed. • Extend. When you extend text, the spaces between characters are made larger by an appropriate amount. The characters themselves are not changed.

Reading notes: Garbled characters in the Outline and Shadow style examples (e.g., 'Omilliime', 'Owtllfume cllDsnrac1iell') appear to be damaged OCR. Reading order of the style list is uncertain where text is interleaved with sample lines.

Languages
English