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

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

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

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

Transcribed text:

Listing 9-14. A Program That   Emulates   the   MacPaint   Circle   Tool,   but is Written   Entirely   in   MS-BASIC.
10   REM   SAMPLE   MACPAINT   CIRCLE   DRAl,JJNG   ROUTINE   IN   MS-BASIC
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE(O)
50   XX=MOUSE<3)
60   YY=MOUSE(4)
70   IF   B=-1   THEN   80   ELSE   40
80   B=MOUSEO:O)
90   IF   B=-1   THEN   CIRCLE<X,Y)   ,H,30
100   X=MOUSE(l)
110   Y=MOUSE<2)
120   IF   8=0   THEN   160
130   H=ABS<YY-Y)
140   IF   B=-1   THEN   CIRCLE<X,Y)   ,H,33
150   GOTO   80
160   X=O:Y=O:XX=O:YY=O
170   GOTO   40
are   substituted for the   LINE   statements.   The
radius of the circle is represented by H and is
determined by subtracting the current   Y   coordinate
from the starting   Y   coordinate represented by   Y   and
YY,   respectively.   The ABS function   (absolute
value) is used in line   130   to always return a positive
value for the radius. For instance, if   YY   is equal to
10 and   Y   is equal to 50, Jet's say, the value would be
-40. However, the ABS function converts   -40   to
+40. Therefore, we always have a legal value to
use for the circle radius.
Listing 9-15 shows a program listing that al-
lows the keyboard to interface with the mouse.
Here, you determine the point on the screen where
text is to be written by placing the mouse pointer at
that location and clicking once.   You   then type the
word, phrase,   or sentence via the keyboard and
press RETURN.   You   can then move the pointer to
another location and do the same. The   MOVETO
subroutine is used in Jines 80 and   100   to position the
cursor at the coordinates returned by   MOUSE(l)
and   MOUSE(2).   Line   llO   uses the INKEY$ func-
tion to allow text to be entered.   If   nothing is entered
via the keyboard, a loop is set up between lines   llO
and 120. However, when any key is pressed, it is
assigned to A$ and printed by line 150. Line 140
tests for the   RETURN   key being pressed. In ASCII
code, this key is represented by decimal number
13, so CHR$ (13) represents the   RETURN   key.
The CHR$ function returns the character equiva-
lent of an ASCII number of the key pressed. When
RETURN   is pressed (A$ = CHR$(13)), line   140
branches to line   40   and the routine begins again,
allowing you to   position the mouse pointer at
another location on the screen.
MOUSE(5)   AND   MOUSE(6).   MOUSE(5)
and   MOUSE(6)   work very much like   MOUSE(3)
and   MOUSE(4),   except these functions return the
ending X and   Y   coordinates.   If   the button was down
the last time   MOUSE(O)   was called,   MOUSE(5)
returns the horizontal coordinate at the time of this
call.   In this manner,   it works very much like
189

Reading notes: Source contains OCR-style spacing artifacts and possible character errors (e.g., 'DRAl,JJNG', 'MOUSEO:O)', 'Jet's say'), so exact spellings may be unreliable. Reading order is interrupted between the listing and the following prose, which begins mid-discussion.

Printed product names: MacPaint · MS-BASIC · MOUSE · CIRCLE · INKEY$ · CHR$ · MOVETO · ABS

Printed dates: 2/84

Languages: English

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

### PDF page 200

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

Listin1 9-15. A Program for Placing Text at Set Points on the Screen by Clicking the Mouse.

Transcribed text:

Listin1   9-15. A Program for   Placing   Text at   Set   Points on the Screen   by   Clicking   the Mouse.
10   REM   BASIC   TEX T   SETTING   MOUSE   ROUTINE
20   REM   COPYRIGHT   FREDERICK   HOLTZ   2/84
30   CLS
40   B=MOUSE<O )
50   X =MOUSE ( 1)
60   Y=MOUSE(2)
70   IF   B<>O   THEN   80   ELSE   40
80   CALL   MOVETO<X, Y)
90   PRINT   CHR$(91)
100   CALL   MOVETO<X,Y)
110   A$=INKEY$
120   IF   A$=""   THEN   110
130   B=MOUSE   < 0)
140   IF   A$=CHR$<13)   THEN   40
150   PRINT   A$;
160   GOTO   110
MOUSE(!),   but if the button was up,   MOUSE(5)
returns the horizontal coordinates of the mouse
when the button was released.   MOUSE(6)   does the
same thing,   for the vertical coordinate.   These
functions are often used to determine the ending
point when the cursor has been moved.
190
SUMMARY
The mouse and the Macintosh go hand in hand.   So   do the
mouse and the   Microsoft   BASIC.   Programming   the mouse
makes it possible to set up programs that use the mouse rather
than the keyboard. With the mouse, you can set up some drawing
functions that are not currently available in   MacPaint.   Fortu-
nately,   the lowered speed of an interpreter as compared to
machine language subroutines is not usually a major problem
when the computer is used as a drawing board.   Using the
MOUSE   function,   you can emulate much of what is already
available in other programs provided for the Macintosh, but you
can also set up your own functions to better suit your particular
needs.

Reading notes: Heading spacing and 'TEX T' spelling in the OCR-like source may reflect extraction artifacts. Text fragment 'MOUSE(!)' may be an OCR misreading of MOUSE(1).

Printed product names: MacPaint · Macintosh · Microsoft BASIC

Printed dates: 2/84

Languages: English

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

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