Lingo Dictionary > A-C > alertHook

 

alertHook

Syntax

the alertHook

Description

System property; specifies a parent script that contains the on alertHook handler. Use alertHook to control the display of alerts about file errors or Lingo script errors. When an error occurs and a parent script is assigned to alertHook, Director runs the on alertHook handler in the parent script.

Although it is possible to place on alertHook handlers in movie scripts, it is strongly recommended that you place an on alertHook handler in a behavior or parent script to avoid unintentionally calling the handler from a wide variety of locations and creating confusion about where the error occurred.

Because the on alertHook handler runs when an error occurs, avoid using the on alertHook handler for Lingo that isn't involved in handling an error. For example, the on alertHook handler is a bad location for a go to movie statement.

The on alertHook handler is passed an instance argument and two string arguments that describe the error. Depending on the Lingo within it, the on alertHook handler can ignore the error or report it in another way.

Example

The following statement specifies that the parent script Alert is the script that determines whether to display alerts when an error occurs. If an error occurs, Lingo assigns the error and message strings to the field cast member Output and returns the value 1.

on prepareMovie
	the alertHook = script "Alert"
end

-- parent script "Alert"
on alertHook me, err, msg
	member("Output").text = err && msg
	return 1
end