REALbasic for HyperCard Usersby Matt Neuburg
A computer is made to program, and what made the Macintosh a viable computer for me in 1990 was HyperCard, the scriptable interface construction kit and freeform database from Apple Computer. HyperCard allowed you simply to draw your program's interface, and then associate interface items with code responding to related user actions -- for example, in the case of a button, what should happen when the user pressed it.
But the Apple folks never really understood the brilliance of HyperCard, or how essential it was to the user community. They stopped giving HyperCard away for free, handed it over to Claris, and then took it back again. They nearly killed it, but then gave it a new lease on life for a while, and have now given up on any further development. Unsupported, HyperCard has begun to grow long in the tooth, showing signs of misbehavior under recent operating systems. This situation has long been bemoaned in TidBITS, the online journal for which I'm a contributing editor; and the search for the "new HyperCard" has more recently been taken up on O'Reilly Network.
For many of us, however, the new HyperCard is already here. It's REALbasic, the integrated development environment and application framework from REAL Software. Like HyperCard, REALbasic lets you draw the interface and assign code to its pieces. Indeed, you can drag a button and a text field into a window, and presto, without any code at all, you've written an application where the user can press the button, type into the text field, move or dismiss the window, and choose the Copy, Paste, and Quit menu items. And REALbasic has some major advantages over HyperCard:
It generates true compiled standalone applications that run natively on Mac OS 8/9, Mac OS X (Carbon), and even Windows, as opposed to HyperCard's interpreted "stacks" which required the presence of HyperCard itself (these stacks will never be Carbonized and are not cross-platform).
Its interface integrates color, graphics, and a full range of genuine Appearance Manager/Aqua widgets, as opposed to HyperCard's lack of color, primitive graphics, and flat, "false" buttons and scrollbars.
It uses an easy, efficient language, with genuine object-oriented programming and custom data structures -- as opposed to HyperCard's verbose HyperTalk, simplified event-passing and messaging mechanisms, and simple-minded "item/line" strings.
It supports drag-and-drop, file and clipboard manipulation, Internet communications, animation, and many other functions that in HyperCard, if they were possible at all, would require an XCMD.
My introduction to REALbasic
My life with REALbasic started in 1998 with a couple of weeks of intense investigation. At first, my HyperCard experience actually hampered me; but once I had shed my attachment to the card/background metaphor and to HyperCard's style of event-passing, I found REALbasic to be extraordinarily congenial, wrote several programs with it very quickly (that in HyperCard I would have found well-nigh impossible), and ended up writing a book about it for O'Reilly & Associates. On my computer, where once I reached automatically for HyperCard for all scripting needs and custom solutions, HyperCard today plays no role at all. What I automatically reach for is REALbasic.
Still, while I'd encourage users of HyperCard to look into REALbasic, there are also some potential pitfalls and disappointments to be aware of. There are certain things that, while dead easy in HyperCard, are much more difficult or even impossible in REALbasic. In particular, these tripwires include:
HyperCard's card/background metaphor supports a light database where storage, display, and searching come more or less free; in REALbasic, you have to work quite hard to achieve the same effect.
The very artificiality of HyperCard's interface allows the programmer to obtain information about it and control over it to an extent that in REALbasic is not so easily obtained.
To give a simple example, in HyperCard you can simulate a click anywhere; that's not possible in REALbasic. You can usually work around this by structuring your program differently, but the point is that you do have to structure your program differently than what you are used to, and previous users of HyperCard may initially be put off by this.
Preparing to build a REALbasic application
I'm going to illustrate some of these points by constructing a small REALbasic application intended to copy an actual and fairly typical HyperCard stack. Let me start by describing the stack.
In 1991, Project Gutenberg (an early purveyor of free electronic public-domain texts) published a text file based on the 1911 Crowell edition of Roget's Thesaurus. This text is full of typos and archaisms, but it has a certain classic charm. The next year, Mark Zimmerman reformatted this text as a HyperCard stack; a card consists of the text of one entry, along with three headings at the top displaying the entry's
section classifications. A while later, I adapted this stack further, adding a hyperlinked search capability and an index card for lookup and navigation by class, part, and section.
In this article, I'll rewrite that stack as a REALbasic application. My purpose isn't to teach you any REALbasic -- see my book for that -- but rather to concentrate on the changes involved. Why? Because these changes reflect the typical differences between HyperCard and REALbasic, and illustrate the mental shift you'll have to make as you migrate from one environment to the other.
As part of the exercise, I'll try to make the REALbasic application look and act as much as possible like the original HyperCard stack. In real life, though, you'd probably want to rethink the interface as well.
Here's the index as displayed by REALbasic. The user clicks on a class heading from the list at the top center of the window. The list at the middle left displays the section headings belonging to that class. The user then clicks a section heading. The list at the bottom displays that section's part headings. The user clicks a part heading; the list at the middle right displays that part's actual word entries. Finally, the user clicks a word entry to display it.
Here's what happens after the user clicks "573. Diffuseness" from the middle-right list in the index: The entry for "Diffuseness" is displayed. It looks much like Mark Zimmerman's original HyperCard stack, but I've added some text styling to make the entry easier to read and there are some navigation buttons at the bottom. Plus a fourth heading is displayed at the top, which is really just a copy of the first line of the entry.
From here, the user can navigate to the previous or next entry (572 and 574) using the arrow buttons at the bottom. Or, the user can click any heading to navigate by heading. Or, the user can click an entry number within the entry text to navigate to that entry -- for example, clicking "577" at the end of the second paragraph brings up entry 577 ("Inelegance"). Or, the user can click any word in the entry to search for the next occurrence of that word.