HyperCard Programming
Volume Number: 3
Issue Number: 10
Column Tag: Stack Programming
HyperCard's User Friendly Programming 
By Fred Stauder, Ecofin, Research & Consulting, Zurich, Switzerland
What is HyperCard?
Hypercard created by Bill Atkinson and friends will create a paradigm shift in
the way we look at the Macintosh and information retrieval. What exactly is it? It isn’t
exactly anything, it is a number of tools and concepts expertly moulded into a user
friendly application generator and viewer. The closest way to think of it is, a cross
between MacPaint, Guide and Smalltalk. It is best described as an object oriented
authoring tool and information organiser. It is simple, fast and very powerful.
In our modern age with the information explosion it is hard to keep track of data.
Information stored in books, is often easier to access than that on a computer. With a
book we can go to the index which gives us a link to a particular page, for example a
chapter heading. The way we use reference books is usually non-linear. The term
Hypermedia was coined in the late 60’s to refer to computer supported non-linear
information media with multiple paths between ideas. Hypercard is one of the most
powerful forms of Hypermedia we have today. It’s applications vary from phone
number databases to driving Laserdiscs.
HyperCard Objects
The main building blocks, or objects, of Hypercard are; Backgrounds, Cards,
Fields and Buttons (Fig.2). A Hypercard application is known as a “Stack”. A Stack is
made up of Hypercard objects. A Stack is made up of Hypercard objects and graphics
(such as the book in Fig. 2). Each of these objects contains a Script. The Script
language is called Hypertalk and is based on English and influenced by Pascal.
When you launch Hypercard you first go to the Home Stack and the first Card is
Called the Home Card (Fig. 1). The Home Card is important, no matter where you are
in any Stack you can select the “Home” menu item under the “Go” heading and it will
take you to the Home Card. You navigate through Cards and Stacks using the Browse
tool, this is a cursor that looks like a hand (top right corner of Fig. 1). The icon like
pictures in Fig. 1 are called Buttons. Buttons take you from Card to Card or perform a
multitude of tasks. For example playing digitised sounds or advancing to the next
frame on a Laserdisc. To go to the Calendar you click on that Button. This is in contrast
to the Finder where you double click an icon to go to an application.
Fig. 1 Home Card
Hypercard appears superficialy as a simple program because most of its
structure and functionality is hidden from the user. There are 5 user levels within
Hypercard. The top most level, and easiest to use, is Browsing. This allows the user to
navigate through Stacks and look at information but not to add or modify it. The next
two levels Typing and Painting allow the user to add or modify written and graphic
information. The last two levels are Authoring and Scripting. Authoring allows use of
the Field and Button tools and Power Keys (short Cuts). The Scripting level allows full
use of the Hypercard programming language called Hypertalk, and the use of instant
commands called “Blind Typing”. [Note that Hypercard offers a protection mechanism
forstacks that allows programmers protection via a menu item. This pr events scripts
from being read.]
Tools of the Trade
Hypercard has a number of tools to help in the development and customization of
Stacks. There are Paint Tools (Fig. 3) that work much like MacPaint but with many
more powerful features. One of these features is that you can use these tools directly
from Hypertalk.
The Tools and Patterns are on “Tear Off” menu’s. You simply drag the cursor to
the bottom or sides and the menu’s tear off, then they act as windows. As well as the
paint features in the tools menu you can select a Button tool , and a Field tool , as well
as the Browse tool. The Button tool (next to the Browse tool Fig. 3) lets you manipulate
Buttons (cut, copy, paste, resize, etc.). By double clicking a button you can assign or
change attributes (Fig. 4) and enter the Script Editor (Fig.5). Entering the Script
editor directly is possible by double clicking the Button while holding down the shift
key. The Field tool does basically the same thing except for Fields. One difference is
that with Buttons you can add an Icon and link it automaticaly to another card, and with
Fields you can change font attributes.
Fig. 2 Hypercard Elements
The Message box which is a long rectangular text entry window (Fig. 3) is a
powerful tool. It is used to give Commands and get Functions (like an instant window).
For example you can type in “go to next card” then press enter or return and the
action will take place immediately. This is very useful to test script ideas. When the
user sets preferences to “Blind Typing”, he can type into a hidden Message Box. This
allows instant Hypertalk access directly from the keyboard at any time.
Fig. 3 Hypercard Tools
The Script Editor allows you to enter and modify Scripts. It automaticaly does the
formattng for you. The window is scrollable vertically but of fixed size horizontally.
Sometimes script lines can be longer than the window, this is allowable, you just
won’t see the rest of the line. Or you can put in a “soft” return by typing in an
option-return, which allows visual splitting of lines but still retaining the line
integrity. This is displayed by an special character. You can cut, copy and paste from
and to scripts using the editor but only with command keys (command-c, etc.). The
reason for this is that the editor is really a dialog box. You can also search using
command-F. Printing of scripts is possible from the editor or from Hypertalk itself.
Behind the Scenes
Let us begin by looking at a few basic concepts of Hypertalk. Hypertalk is built
around a system that sends messages to objects. A message is basically a command or
function. The Hypercard application sends messages about the current state of the
Macintosh and Hypercard to objects, each object responds to messages depending on its
script. Hypercard has an object message hierarchy as shown in Fig. 6. For example if
the mouse is pressed, Hypercard sends out a message “mouseDown” . If the tool cursor
is on a Button, a “mouseDown is sent to that Button, if there is no Button or textField
under the tool the message is passed on to the Card. This message travels up the
hierarchy until it reaches a level with a script begining with “on mouseDown”.
It then executes the instructions following “on mouseDown “until it reaches “on
end mouseDown” at the end of the script. If there is no recipient of the message as it
passes up the hierarchy it simply vanishes at the top. Messages are passed from
Buttons and Fields etc. through the hierarchy up to the Hypercard application.
When Hypercard seems to be doing nothing it is passing messages down the
hierarchy. For example if nothing is happening it sends a message “Idle” to the Home
Stack which passes it to the current Stack in turn passes it to the Background which
passes it to the Card which passes it to the Buttons and Fields.
Fig. 4 Button Info
Fig. 5 Script Editor
Normal programs are self contained, that is they have a “begin” and an “end”.
Hypercard on the other hand has individual parts of a program within the objects it
relates to. This has the advantage of being modular. For example, if you like the
function of a button that puts a time and date stamp in a selected field, you can easily
copy and paste that button into any stack.
Fig. 6 Message Hierarchy
Fig. 7 Secret Stack
Hypercard also has some limitations, you are limited to the size of a normal
Macintosh screen, no color, and you can view only one card at a time. Some of these
limitations have already been addressed, such as the introduction of scrolling fields
which aid the size limitation.
The Secret Diary
I have written a short example Stack Called Secret Diary. I will use it to
demonstrate the format and Ideas behind scripts. Let me fist describe what the Stack
does. When you open it you are confronted with the same Card as in Fig. 7. When you
press Button “Push to Start” up comes an alert box warning you to remember your
password, then up comes a dialog box asking you to enter a password (Fig.8). A second
dialog box pops up asking you to confirm your password, then an alert telling you your