Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference »

Note: This is a work in progress and many formatting issues have been fixed. Read more about the project on the home page.

Writing message handlers

When you write a handler for a message, you specify a sequence of statements for HyperCard to run. Each message handler has the following form, with the italicized words as placeholders:

on messageName
statements
end messageName

When it runs the message handler, HyperCard sends each line of the handler as a message itself (so handlers can call other handlers).

Important: The message name does not have to be one of HyperCard’s built-in system messages or commands.

For example, if you wanted a new command called doubleBeep that would beep twice, you would write a handler for it as follows:

on doubleBeep
beep
beep
end doubleBeep

Of course, HyperCard doesn’t know about the doubleBeep command, so it will never be sent automatically in response to an event. But you can send doubleBeep from the Message box or use it as a statement in other handlers.

For example, the script of a card button might contain the following handler for the system message mouseUp:

on mouseUp
doubleBeep
end mouseUp

If the script also contains the doubleBeep handler (or if the script of any object later in the message-passing path contains it), the mouseUp message will send the doubleBeep message, and doubleBeep will send two beep commands. Because beep is a built-in command, HyperCard beeps twice.

If HyperCard can’t find the doubleBeep message, it will complain (with a dialog box) that it “can’t understand” the message.

Related Topics

Placeholders

messageName

Any text string, without quotation marks, that represents the name of the message handler you want to write:

calculateDebt
selectWholeLine

As in:

on calculateDebt
on selectWholeLine theLine, aContainer

statements

Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.

put "Hello world" -- built-in command
get total(field 1) -- function call
global HelpInfo -- keyword

HyperTalk Reference


Version 0.8b4 (July 4, 2025)

Made with Macintosh

Switch to Modern View