# Using & Programming the Macintosh: Including 32 Ready-to-Run Programs — source transcripts, page 2

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2)

## 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.

### PDF page 12

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-a9cf47c1a71a60ff1dc7faf7ecc3b01662f9ced693462ec4bce5cee1336ac525)

Transcribed text:

to use these personal computers required a large
investment of the individual's time. And there was
generally a phobia surrounding the computer. As a
result,   a large number of potential users have
stayed away from computers.
The folks at Apple decided that if the market
for personal computers was to grow, people could
not be forced to acquire special skills. When used to
type a letter, for instance, the computer should
resemble a typewriter. When used to prepare a
diagram,   the computer should function like a
sketchpad.   People   want the computer to respond in
ways that are familiar and consistent, regardless of
what it does.   They are awaiting the computer
equivalent of the automatic transmission.
The Xerox   8010   Workstation   (Star)   was the
first computer system to embody features that   at-
tempted to make computers easy to use and   under-
stand. It offered a powerful   "user   interface"   that
simplified the system's operation.   Symbols   and
graphics, rather than coded messages, represented
the computer's different resources. And the   Star
used   pointing   technology, where the   mouse,   like a
joystick, moved   the   cursor around on the screen.
The   Star   made great strides toward using, learning,
and understanding computers. But its dependence
on a large network made   Star   impractical for small
installations.
In   January 1983, Apple Computer introduced
its Lisa computer shown with the Macintosh in Fig.
1-1, a personal computer that improved the   con-
cepts used in   Star   and increased its simplicity and
usefulness. And Lisa could be used as a stand-alone
work station, so offices could start with one and add
others as needed. Additionally, Lisa used a   micro-
processor with a 32-bit architecture, allowing it to
handle even more data than the 16-bit chips that had
only recently been so impressive.
Lisa was to revolutionize the way people   in-
teracted with microcomputers. No longer would it
be necessary for the user to learn a computer Ian-
2
guage. All you had to do was turn the computer on
and,   instead of typing English words to tell the
computer what you wanted to do, you used the
mouse to move the cursor to picture symbols on the
screen, called   icons.   If   you wanted to access a
floppy disk, you simply used the mouse to place the
cursor on the disk icon displayed and then pressed
the mouse button. The computer automatically   ac-
cessed the floppy disk in the drive.
As Apple stated quite accurately,   a person
with absolutely no computer experience could sit
down at this machine and draw sophisticated
graphics within a half hour or so.
Another feature that made Lisa unique among
microcomputers was that no high-level language
was offered for the machine. It was never meant to
be   programmed   by the average user. Rather, Apple
supplied the programs the user might need,   in-
cluding graphics programs, a word processor, and
various business packages.
Lisa,   though,   was considerably less than a
booming success for Apple. The machine simply did
not catch on with a large segment of the market.
Certainly, one reason it did not was the price,
abutting   $10,   000.   Lisa was intended as a   busi-
nessman's machine and the price reflected this   in-
tention. Another reason for its less than spectacular
showing was that most software was only available
for the IBM   PC   and similar hot-selling machines.
Because the Lisa concept was untested, few   com-
panies supported it with software. Undoubtedly, a
large number   of computer buyers were simply
afraid to take a chance on   buying such an expensive
machine for which there was limited software   sup-
port.
Rumors were circulating that Apple, who had
reportedly spent   $10   million dollars on the Lisa
project, was in serious trouble. The Apple II series
of computers had been a mainstay of the company
for many years. At one time, the Apple was   th£
microcomputer manufacturer,   and even today,

Reading notes: Possible OCR damage in 'abutting $10, 000' and 'th£ microcomputer manufacturer' Source text is an excerpt ending mid-sentence; reading order beyond the final line is unknown

Printed product names: Xerox 8010 Workstation (Star) · Star · Lisa · Macintosh · Apple II · IBM PC

Printed prices: $10,000 · $10 million dollars

Printed dates: January 1983

Languages: English

[Original PDF page 12](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=12)

### PDF page 188

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-4a7d3cc8becb2d4814eb720b1600b093ab933837a1793746ed135cda9c91e295)

Transcribed text:

Chapter 9
CIRCl£   PRTTERN
PrograDlnting the Mouse
A mouse is simply another type of input device or
user interface, just like a keyboard, light pen, or
joystick. The mouse most closely resembles the
joystick. Almost everyone today is familiar with the
joystick. It is the hand-controlled device included
with most video games that allows the user to
control on-screen object animation. A mouse is just
a modified joystick that inputs information to the
computer by its position on a table surface instead
of by the position of a lever.
Unlike   a joystick that moves an on-screen cur-
sor in the direction the lever is pointing as long as
the lever is held in that position, the mouse moves
across the table in the direction the cursor should
move. A small ball within the mouse tracks across
the surface of the desk or tabletop and tells what
direction to move the cursor. In other words, the
cursor moves as long as the mouse moves in the
same relative direction. For this reason, a mouse is
generally easier to use than the joystick.
Although generally a joystick can provide a
178
little more accuracy in pinpointing precise locations
on the screen, the Apple Macintosh   mouse   is an
extremely smooth performer. It tracks very well
and quite precisely. The rubber ball that mounts in
the bottom cover of the mouse can be easily re-
moved for cleaning by rotating the circular disk clip
that holds it in place. By rotating the disk coun-
terclockwise, it will slip out of the mouse cover and
the ball can be dropped out, so both the ball and the
well that holds the ball can be cleaned. Dust can
accumulate in its well, so it's a good idea to clean
the mouse about once a week. The Macintosh man-
ual provides complete instructions for performing
this preventive maintenance.
Some   persons think there is something magic
about a mouse, but it's really far simpler than most
other types of input devices. When running   Mac-
Paint   or   MacWrite,   the mouse is easy-to-use when
accessing different icon tools and positioning the
cursor at different points on the screen. When the
computer is first activated,   programs in the

Reading notes: Chapter heading and title line are garbled by OCR ("CIRCl£ PRTTERN", "PrograDlnting"), so exact heading wording is uncertain. Source text ends mid-sentence, so the closing portion of the copy is missing.

Printed product names: Apple Macintosh · MacWrite

Languages: English

[Original PDF page 188](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=188)

### PDF page 189

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-e7378d98355b030aac33c9fd62621c738dbade14a91cf31cdf2d3b356ff79547)

Transcribed text:

Macintosh   ROM   are automatically loaded into cur-
rent memory, which allows the computer to read
information returned by the position of the mouse.
Fortunately, Microsoft   BASIC   allows us to write
our own special programs that can make use of the
mouse in different ways.
THE   MOUSE   FUNCTION
In   Microsoft   BASIC,   we tise   the   MOUSE
function to perform seven different programming
functions , depending on the argument used. Here,
the   MOUSE   function is just like most other func-
tions in Microsoft   BASIC.   It returns a specific value
to a numeric variable when executed. Its format is
X   =   MOUSE(N)
where N is a value of   0   to 6. Depending on the
number substituted for N,   the   MOUSE   function
may return different information about the status of
the mouse button or the position of the mouse
pointer on the screen.
MOUSE(O).   When the   MOUSE   function is
used with a   0   subscript or   argument,   it returns a
value ranging from -3 to 3. Each of the seven possi-
ble values indicates the condition of the   mouse
button. The format is:
X =   MOUSE(O)
When this line is executed, a value of from -3 to +3
is returned to X, depending on the status of the
mouse button.   If   X is equal to   0   when this line is
executed, this means that the mouse button is not
currently being pressed and has not been pressed
since the last time this function was executed.   If   the
number 1 is returned to X, the mouse button is still
not currently down, but it has been clicked once
since the last time the function was executed.
When X is equal to 2, the button is not down,
but has been clicked twice. A 3 indicates that it was
clicked three times (as in a third level selection).
When Xis equal to -1, this means the mouse
has been clicked once and the button is still being
held down. A-2 indicates two clicks with the button
held down, and a -3 indicates three clicks with the
button held down.
What is the purpose of this information? The
purpose is to tell the computer the exact status of
the mouse button and to have it execute certain
subroutines depending on the status. The program
shown in Listing 9-1 keys on a condition of the
mouse being clicked once. Line   30   clears the
screen, and the   MOUSE(O)   function is used in line
40   to assign to X the value of the mouse button
condition. Don't be confused here.   MOUSE(O)   de-
termines the condition of the mouse button, and the
variable X is assigned that value. Line   60   uses an
IF-THEN statement to test for a condition of X
being equal to 1, which would indicate a single click
of the mouse button.   If   MOUSE(O)   returns any
number other than   1,   the   ELSE   portion of this
statement simply branches back to line   40,   where
the condition of the mouse is read again. When X is
Listing 9-1 . A Program That Prints a Message When the Mouse   Is   Clicked   Once.
10   REM   BASIC   MOUSE   BUTTON   PROGRAMCONE   CLICK)
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   : :<=MOUSE(   0 )
60   IF   X=l   THEN   PRINT"YOU   PRESSED   THE   MOUSE   BUTTON. "   ELSE   40
70   END
179

Reading notes: Line 40 OCR reads ': :<=MOUSE( 0 )' which may be a damaged rendering of 'X=MOUSE(0)' Listing 9-1 text partially garbled in extraction

Printed product names: Macintosh · Microsoft BASIC

Printed dates: 2/84

Languages: English

[Original PDF page 189](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=189)

### PDF page 190

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-0e8ca2d1a1eba0798434f49736033c35f65c64daa40ac16e5befa7f192ae1aa1)

Listing 9-2. The Message Is Now Printed by Clicking the Mouse Twice.

Transcribed text:

Listing 9-2. The Message   Is   Now   Printed   by   Clicking   the Mouse Twice.
10   REM   BASIC   MOUSE   B UTTON   PROGRAM C TWO   CLICK >
20   REM   COPYRIGHT   FR EDERICK   HOLTZ   2/ 84
30   CLS
4 0   : :<=MOUSE( O)
60   IF   X=2   THEN   PRINT"YOU   PRESSED   THE   MOUSE   BUTTON   TWO   TIMES."   ELSE   40
7 0   END
equal to   1,   the   phrase   "YOU   PRESSED   THE
MOUSE   BUTTON"   is displayed on the screen. Try
this program and you will find that anytime you hit
the mouse button, the message will be displayed on
the screen.   You   must simply tap the mouse button
and then release it in order to print the message.   If
you press once and hold, the message will not be
displayed until you release the button. This is due
to .the fact that we are testing for a condition of X
being equal to 1 and it will only be equal to 1 when
the mouse button is clicked and then released.
The program in Listing 9-2 performs in the
same manner as the one in Listing 9-1, only in this
case, line   60   tests for a condition ofX being equal to
2. This is the number returned to X when the button
is clicked two times and then released.   If   you press
the mouse button once and release, nothing hap-
pens. When it's clicked twice, the message is dis-
played.
Listing 9-3 shows the same type of program
set up to respond to three clicks of the mouse. Note
that allthree programs are extremely simple and do
not present any unique programming problems.
Line   40   does it all by assigning to X the mouse
button condition. As long as we know what numbers
are returned based upon the various conditions the
button can assume , programming is quite simple.
Listing 9-4 shows a program set up to test for a
condition of X being equal to -1, which means that
the mouse button has been clicked once and held.
This program is a bit different from the previous
three, as it contains an extra line. Line   50   is a delay
loop. The delay is required because we're trying to
set up a sequence whereby the message will not be
displayed unless the mouse button is clicked once
and held. Without this loop, line   40   is being exe-
cuted so rapidly within the loop   (ELSE   40)   that it's
almost impossible to click and release the mouse
button before the   MOUSE(O)   condition is read. By
slowing down the execution, line   40   is not executed
as rapidly, because it takes longer for the branch at
the end of the line   60   to be activated. Therefore, if
you simply clicked and released the mouse button, a
1 would be returned.   If   line   40   were being executed
Listing 9-3. A   Program   Where When the Mouse   Is   Clicked   Three Times,   X   is   Equal   to 3, and the Message is   Printed.
10   REM   BASI C   MOUSE   B UTTON   PROG RAM C THREE   CLICK )
20   REM   COPYRIGHT   FREDERi tK   H O LTZ   2/ 84
3 0   CL S
40   X =MOU SE <O   :i
60   IF   X =3 TH EN   PRI N T"YOU   PRESSED   THE   MOUSE   BUTTON   THREE   TIMES."ELSE40
70   END
180

Reading notes: Line-break hyphenation and OCR spacing artifacts in BASIC listing text Garbled characters in 'FR EDERICK' and 'FREDERi tK' copyright lines

Printed dates: 2/ 84

Languages: English

[Original PDF page 190](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=190)

### PDF page 191

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-e24854c5e6c6c0e8cba0dc16a592f8ec6f6ffc2213d97a44190b9623f2e6506b)

Transcribed text:

Listin&   9-4.   A Program That Displays the Message When the Mouse Button   Is   Clicked   and Held.
10   REM   BASIC   MOUSE   BUTTON   PROGRAM   <ONE   CLICK   HOLD)
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/ 84
30   CLS
40   X=MOUSE<O:>
50   FOR   DLAY=1   TO   750:NEXT   DLAY
t .O   IF   :X=-1   THEN   PRINT"YOU   ARE   PRESSING   THE   MOUSE   BUTTON."   ELSE   40
70   END
faster than you could click and release, everytime
you pressed the mouse button, a -1 would be re-
turned. This happens because you cannot click and
release faster than the computer can read the value
of X. The time delay loop gives the user time to
click and hold (-1) or to click and release (1). Since
we're looking for -1,   the message will only be
printed when you click and hold the mouse button.
Try running this program as it appears and then
remove the time delay loop and try it again.   You   will
find that when the time delay loop is removed,
every time you press the button, whether you hold
or not, the message will be printed.
The program in Listing 9-5 allows you to see
the numbers that are returned to X for the number
of times you click the mouse button and whether or
not it is currently up or down. This is just like the
previous program, except there is no IF-THEN-
ELSE statement. Line   40   assigns to X the value of
the condition of the mouse button, while line 41
prints the value of X on the screen. Line 45 is a time
delay loop, while line   60   simply branches to line   40
to again test for the condition of the mouse button.
When you run this program,   you will im-
mediately see a column of zeros being printed on
the left side of the screen. This means that the
mouse button is not being pressed. Therefore, X is
equal to   0.   If   you click the button once, the number 1
will be displayed. Two or three clicks will return
the numbers 2 and 3.   If   you click once and hold, a -1
will be printed on the screen. This program dem-
onstrates the   many conditions   possible   when
monitoring the mouse button.
MOUSE(l).   The mouse programs shown thus
far address only the condition of the mouse button.
The   MOUSE   function can also tell the current,
starting, or ending X,   Y   coordinates, but cannot do
this until the   MOUSE(O)   function is executed first.
Therefore, in every program that uses any   MOUSE
function, you will always see at least one reference
to   MOUSE(O).
The MOUSE(l) function determines the cur-
Listing 9-5. A   Prozram   That Prints the Number That Represents the Mouse Button   Condition.
10   REM   BAS!   C   MOUSE   BUTTON   PROGRAM<VARIABLE   CLICKS   AND   HOLDS)
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   X=MOUSE(O)
41   PRINT X
45   FOR   DLAY=l   TO   750:NEXT   DLAY
60   GOTO   40
181

Reading notes: Listing 9-4 header text and code line 60 contain OCR-like spacing and possible character damage Copyright date '2/ 84' appears in program comments

Printed dates: 2/84

Languages: English

[Original PDF page 191](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=191)

### PDF page 192

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-871e6c28c11ab2c9b15dbf2918c680d93fc227c7362d333cd19087f48f32cb34)

Listinz 9-6. A Pro1ram That Prints the X Coordinate Value of the Mouse Pointer Location.

Transcribed text:

Listinz   9-6. A   Pro1ram   That Prints the X Coordinate Value of the Mouse Pointer Location.
10   REM   DEMONSTRATION   OF   MOUSE(   1)
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE(O)
50   X =MOUSE<l:>
60   PRINT X
70   GOTO   40
rent X   coordinate. This is the value of the horizontal
coordinate of the   screen location of the mouse
pointer at the time the   MOUSE(O)   function was
executed. The program in Listing 9-6 provides an
explanation.
Line   40   assigns to B the condition of the mouse
button. Line   50   assigns to X the horizontal   coordi-
nate of the mouse pointer. Line   60   prints the value
of the horizontal coordinate on the screen. Line   70
·   then branches back to line   40,   where   MOUSE(O)   is
executed again, followed by   MOUSE(l).
We had to use   MOUSE(O)   in this program to
get   MOUSE(l)   to work. In this particular example,
although the value of B is never used, this line must
be executed before   MOUSE(l)   is. You don't have to
press the mouse button when using this program,
since which state the mouse is in makes no   differ-
ence whatsoever.
When you run the program, a column of   num-
bers appears on the left side of the screen. Move
the mouse across the desk and you will see the
numbers change. The last number in the column
represents the current horizontal position of the
mouse pointer on the Macintosh screen.   If   you
place the pointer toward the center of the screen,
you will get a value of about   240.   Its vertical   posi-
tion on the screen makes no difference,   since
MOUSE(l)   only returns the value of the horizontal
coordinate.
This program is a bit awkward to use since it
continuously prints a series of coordinates. The
program shown in Listing 9-7 is a little more   practi-
cal.   The program is very similar to the one in
Listing 9-6, but here the value of   B   which indicates
the mouse button state   is   used. This program will
print the X coordinate of the mouse pointer anytime
you press the mouse button, which eliminates the
never-ending column. Line   60   tests for a condition
of B being equal to any number other than   0.   Re-
member, when   MOUSE(O)   returns   0,   this means
Listinz   9-7. A   Prozram   That   Displays   the X Coordinate   Value   When the Mouse Button   Is   Clicked.
182
10   REM   BASIC   MOUSE   X-COORDINATE   PROGRAM
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE(O)
50   X=MOUSE(l)
60   IF   B<>O   THEN   PRINT"X-COORDINATE   =";X
70   FOR   DLAY=l   TO   1000:NEX T   OLAY
BO   GOTO   40

Reading notes: OCR errors in headline and listing text (e.g., 'Pro1ram', 'Listinz', 'OLAY' for DELAY, 'NEX T') Reading order uncertain where caption text ('rent X coordinate') begins mid-sentence Line numbers and some characters such as '<l:>' and 'O' versus '0' are ambiguous

Printed product names: Macintosh

Printed dates: 2/84

Languages: English

[Original PDF page 192](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=192)

### PDF page 193

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-f577fb20574579ba246b3c28e37a26802e5a60e2d76d48421f86442da2b45f24)

Transcribed text:

Listin&   9-8. A   Pro1ram   That Prints the   Y   Coordinate   Value   When the Mouse Button   Is   Clicked.
10   REM   BASIC   MOUSE   Y-COORDINATE   PROGRAM
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE(O)
50   Y=MOUSE(2)
60   IF   B<>O   THEN   PRINT"Y-COORDINATE   ="   ;Y
70   FOR   DLAY=l   TO   1000:NEXT   DLAY
80   GOTO   40
the mouse button has not been activated. Run this
program and place the mouse pointer at any location
on the screen.   Click   the mouse button and the X
coordinate value will appear on the screen. Line   70
is the time delay loop again, which prevents two or
three coordinate values from being displayed for
each click of the mouse.
MOUSE(2).   The   MOUSE(2)   function is very
similar to   MOUSE(!),   except here, a value will be
returned that indicates the mouse pointer position
in the Y or vertical plane. The program shown in
Listing 9-8 is nearly identical to the program in
Listing 9-7, but here, line   50   assigns to the Y   vari-
able the number returned by the   MOUSE(2)   func-
tion.
The program shown in Listing 9-9 combines
the last two programs into one. Here, the values of
both the X and Y coordinates will be displayed
anytime you click the mouse button. To achieve
this, line 45 was added to Listing 9-8 to assign to X
coordinate value, and line   60   has been changed to
print the values returned by both   MOUSE(l)   and
MOUSE(2).
Now, what's the value of all that? You can now
use the mouse button and determine its X,   Y   coor-
dinates. With this in mind, you now have the   capa-
bility of supplying needed information to other
programs that can draw objects on the screen,   dis-
play text, or perform many other operations at a
point on the screen specified by the mouse pointer.
The program shown in Listing   9-10   uses the same
principals to allow you to draw on the screen using
the pencil icon just as you would with   MacPaint.
When you run this program, you can position the
mouse pointer on the screen, click, hold, and move
the mouse while drawing a line. In this example, J
Listin&   9-9. A   Pro1ram   That Returns Both the X and   Y   Coordinate   Values   When the Mouse Button is   Clicked.
10   REM   BASIC   MOUSE   X ,Y-CODRDINATE   PROGRA~1
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/ 84
30   CLS
40   B=MOUSE ( 0)
45   : :<=MOUSE   ( 1)
50   Y=MOUSE<2)
60   IF   B<>O   THEN   PRINT"X   =";X;"Y   ="   ;Y
70   FOR   DLAY=l   TO   1000:NEXT   DLAY
80   GOTO   40
183

Reading notes: Garbled OCR in code listing characters (e.g., 'l' vs '1', 'O' vs '0', 'DLAY=l') Reading order uncertain: source mixes Listing 9-8 and Listing 9-9 text and a fragment 'the mouse button has not been activated' appears out of sequence

Printed product names: MacPaint

Printed dates: 2/84

Languages: English

[Original PDF page 193](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=193)

### PDF page 194

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-d7ce80afb456975300c86c5a4772a5ff87ac79807f1f43c84faadb594d043f36)

Listing 9-10. A Simple Drawing Program. When the Mouse Button is Held, a Line is Formed.

Transcribed text:

Listing   9-10.   A   Simple   Drawing   Program.   When the Mouse Button is   Held,   a Line is Formed.
10   REM   MOUSE   DRAWING   PROGRAM
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   X=MOUSE<l)
50   Y=MOLISE<2)
60   J=MOUSE<O)
70   I F J<O   THEN   CALL   LINETO<X,Y>:GOTO   40
80   CALL   MOVETO<X,Y):GOTO   40
represents the button value. As long as it is less
than   0,   this means the mouse button is being held
down. As long as the button is held down, a line is
drawn dot by dot at the coordinates specified by X
and Y. These values are returned in lines   40   and   50.
CALLING   A   ROM   SUBROUTINE
The program in Listing   9-10   uses the   LINETO
call, which is a subroutine contained in the Macin-
tosh   ROM.   These subroutines are listed in the back
of the Microsoft   BASIC   manual and address the
many built-in functions called by the   MacPaint   pro-
gram. These subroutines are always preceded by
CALL   in Microsoft   BASIC.
CALL   is a statement that does just what its
name implies. It calls on assembly language sub-
routines,   or, in this particular case,   an internal
Macintosh subroutine.   LINETO-CALL   works very
much like the LINE statement discussed previ-
ously, but it works faster because it is run by the
Macintosh   ROM.   Line   80   uses another Macintosh
ROM   routine called   MOVETO.   This simply places
the graphic cursor at the point determined by the
values ofX and   Y.   MO   VETO   does not draw a line; it
simply positions the   graphic cursor.   LINETO
draws a line from the current position of the graphic
cursor to the position determined by X and   Y.   The
subroutines are aptly named, since   LINETO   draws
a line, while   MO   VETO   moves the cursor but does
not draw a line.
MOVETO   can also be used to position text at a
specific point on the screen.
PUTTING   THE   MOUSE   TO   WORK
While there are other   MOUSE   functions to
discuss,   let's put what we've already learned to
practical use.   Listing 9-11   shows the   MOUSE
functions used to draw circles of a fixed size at any
Listing 9-11. A Basic   Circle   Drawing   Program   That   Employs   the Mouse.
184
10   REM   MOUSE   CIRCLE   DRAWING   PROGRAN
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE(Q)
50   ><=MOUSE<   1 )
60   Y=MOUSE(2)
70   IF   B<>O   THEN   CIRCLE<X,Y),30
80   GOTO   40

Reading notes: Listing 9-10 BASIC code contains OCR-style character substitutions such as '<l)' and 'MOLISE' and 'MOUSE<O)' that may be misread. Line 40 reads 'MOUSE<l)' and line 50 'MOLISE<2)' which are likely misrecognized characters.

Printed dates: 2/84

Languages: English

[Original PDF page 194](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=194)

### PDF page 195

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-bb411cdad8765c45e7bee9fb6989e302c174a6cf5acdcf53a6c19aa10fa2b41e)

Transcribed text:

point on the screen. Lines   40,   50,   and   60   assign to
B, X, and   Y   the mouse button condition, and   hori-
zontal and vertical coordinates, respectively. Line
70   tests for a condition of the mouse button being
activated. When it is clicked or clicked and held, the
CIRCLE statement is executed and draws a circle
whose center is at the coordinates returned to X   and
Y.   These coordinates are determined by the   loca-
tion of the mouse pointer at the time the mouse
button is clicked. The CIRCLE statement is used
with a radius of   30,   so all of the circles produced will
be that size.
Click and hold the mouse button and draw a
series of circles up and down the screen.   You   must
move the mouse slowly, however, to allow time for
the computer to read new X,   Y   coordinates.
Figure 9-1 shows the circles displayed by this
program when you click the mouse at various   loca-
tions on the screen. Here, individual circles are
displayed at the screen positions you specify.
Figure 9-2 shows what happens when you press and
hold the mouse button and then move the pointer
across the screen.   You   get a   "slinky"   effect.   If   you
pull slowly enough, the various circles are closely
spaced.   If   you pull rapidly, you get an almost   ran-
dom spacing. There is a problem   witp.   this program,
in that   if   you don't like what you draw, you have to
manually halt the program using COMMAND/C
and then run it again. This erases the screen and
you have to start from scratch.
The program in Listing 9-12 uses the mouse
button to clear the screen, so you don't have to
manually halt the program. Line   70   is changed to
include the logical operator   OR.   This simply tells
the computer to draw a circle on the screen as long
as Bis not equal to   0   or 2. Line 75 tells the computer
to clear the screen if B is equal to 2, so you can draw
to your heart's content. When you want to clear the
screen, simply click the mouse button twice and
release. This will return a value of 2 to B, and line
75 will be executed.
These   simple   examples   show   how   the
MOUSE   function can be put to practical use to
display graphics. However, the three functions   dis-
cussed thus far are only the beginning.
MOUSE(3)   AND   MOUSE(4).   MOUSE(l)
and   MOUSE(2)   return the current X and   Y   coordi-
nates of the mouse pointer.   MOUSE(3)   and
MOUSE(4)   also return the X and   Y   coordinates, but
these are not the current coordinates, but rather the
starting coordinates. If you set your program up
properly,   MOUSE(3)   andMOUSE(4)can   be used to
write programs that can replicate some of the   pro-
gramming tools found   in   MacPaint.   When the
mous~   button is first pressed,   MOUSE(3)   and
MOUSE(4)   return to their variables the X and   Y
coordinates of the pointer. However, as long as the
button is held down, the coordinates will remain the
same.   MOUSE(l)   and   MOUSE(2)   will still return
the coordinates of the mouse's current position.
Using   these together allows us to write effective
move programs much like the circle and rectangle
tools found in   MacPaint.   Listing 9-13 is a rectangle
drawing routine that closely simulates the-routine
found in   MacPaint.
Line   40   assigns to B the condition of the mouse
button. Fornow, let's skip lines   50   and   60.   Lines   70
and   80   use   MOUSE(l)   and   MOUSE(2)   to return the
current   X,   Y   coordinates.   Lines   90   and   100   use
MOUSE(3)   and   MOUSE(4)   to return to   XX   and   YY,
the   starling   coordinates. Line   110   tests for a condi-
tion of B being equal to -1, which would indicate that
the mouse button has been pressed and is still
down. When this occurs,   the Microsoft BASIC
LINE statement draws a line from the starting
coordinates   (XX, YY) to the current coordinates
(X, Y). The B (box) option is used, so an open box is
drawn instead of a straight line. Line   120   branches
to line   40,   and another check is made to see   if   the
mouse button is still down.   If   it's not, B becomes
equal to   0.   Line   50   detects this and branches to line
·   130,   which resets all variables to   0.   The image on
the screen remains intact.
Line   60   uses the LINE statement again to draw
185

Reading notes: Source contains OCR-style errors such as 'witp.' and 'Bis' and 'l' for '1' in MOUSE(l), and reading order around line 50 and 60 is unclear.

Printed product names: MacPaint

Languages: English

[Original PDF page 195](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=195)

### PDF page 196

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-d137d7cac8ebcca74e64a6e8e0a01d0fb0346e63148cd607121a6fe2ec16ffe5)

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

Reading notes: No visible text found; the page appears blank white.

[Original PDF page 196](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=196)

### PDF page 197

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-626ceb72b59885ad066964a04405a61a51507ed24e4e18e10004460cf25b7f96)

Transcribed text:

Untitled

Fig. 9-2. Another example of how the basic circle drawing program can produce unusual screen images.

187

Image description: A rotated page showing a black wireframe screen image of a coiled, tube-like looping shape inside a bordered window titled Untitled, with a caption below and page number 187 at the bottom right.

Reading notes: Page is rotated 90 degrees; the title bar text 'Untitled' and caption are read as printed. Faint background text on the page behind the figure is not legible enough to transcribe.

Languages: English

[Original PDF page 197](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=197)

### PDF page 198

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/2#scan-4a271f3a7dc17edc98ad2afdabf4cdd1b5add8fd95d83036b39767ae4dc850d8)

Transcribed text:

Listin11   9-12. An   Improved   Circle   Drawin11   Pro11ram   That   Allows   You   to Erase the   Screen   by   Clickin11   the Mouse Button Twice.
10   REM   MOUSE   CIRCLE   DRAWING   PROGRAM
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE   <   0)
50   X=MOUSE(l)
60   Y=MOUSE<   2)
70   IF   B<>O   OP   B<>2   THEN   CIRCLE<X,Y),30
75   IF   8=2   THEN   CLS
80   GOTO   40
the same line drawn in line   110.   However, there's a
big difference here. Line   60   uses a color number of
30.   This number is optional in line   110,   so it's not
used at all. In line   110,   the computer goes to the
default color represented by 33. This is black, so
the box is seen in black against a white background.
However, with a color number of   30   in line   60,   the
box is drawn in white,   so it is invisible.   More
importantly, this white box is drawn over the black
one, effectively erasing it from the screen. As long
as the mouse button is held down, boxes will be
repeatedly drawn and then erased. This gives the
rubber band or expanding effect you've seen with
the rectangle tool in   MacPaint.   When you release
the mouse button, however, line   60   is not executed
because there is a branch past it to line   130.   This
preserves the last box drawn on the screen.
Listing 9-14 shows a   BASIC   program that
emulates the   MacPaint   circle drawing tool. It uses
the same principals, but here,   CIRCLE   statements
188
Listin11   9-13. A   Pro11ram   That Draws   Squares   and   Rectan11les
Usin11   the Mouse. H Operates Much as One of the Graphics   Tools   in   MacPaint   Does.
10   REM   SAMPLE   MACPAINT   RECTANGLE   DRAl,.JING   ROUTINE   IN   MS-BASIC
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE<O)
50   IF   B=O   THEN   130
60   IF   B=-1   THEN   LINE<XX,YY)-CX,Y)   ,30,B
70   X=MOUSE(l)
80   Y=MOUSE(2)
90   ><><=MOUSEC3)
100   YY=MOUSE(4)
11   0   I F B=   - 1 TH EN   LI NE   < XX ,   Yn   -   <X,   Y ) ,, B
120   GOTO   40
130   :~<=O   :Y=O   :XX=O   :YY=O
140   GOTO   40

Reading notes: Source contains OCR-like character corruption (e.g., 'O' vs '0', 'B=MOUSE < 0)'), so code line spellings are uncertain. Reading order of the interleaved Listing 9-12 and 9-13 text is uncertain at the page break.

Printed product names: MacPaint

Printed dates: 2/84

Languages: English

[Original PDF page 198](https://www.vintageapple.net/files/e026d0823a409095a8d89efb1030163208bbdbd903cc0415b5cab9bdfa11b424/Using_-_Programming_The_Macintosh_1984.pdf#page=198)

[Previous transcribed scans](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/1.md)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-using-programming-the-macintosh-1984-068c1d/3.md)
