Control Structures

shared

Supported By

Syntax

shared variableList

VariableList is a series of one or more variable names separated by commas, each optionally followed by a data type and/or initial value:

variableName [as dataType] [is initialValue]

Description

The shared keyword declares a given variable name as a shared variable whose contents are available to any invocation of any handler in this particular object. If the variable has not already been declared or used, it is created to hold a value of the specified data type and initialized to the specified initial value. If the variable has been declared or used before, its contents remain unchanged.

Changing the value of a shared variable anywhere changes its value for this particular object. The shared keyword must be used in each handler or script in which the shared variable is used.

Notes

The following table illustrates the four different variable scopes, global, local, shared, and static:

global is accessible to any invocation of any handler in any object
shared is accessible to any invocation of any handler in this object
static is accessible to any invocation of this handler in this object
local is accessible to this invocation of this handler in this object

The default data type if none is specified is string. Other data types, particularly variant, may behave in a manner incompatible with HyperTalk, but that may be desirable.

The initial value of a variable, if not specified, is empty.

See Also

global, local, static