local
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
The local
keyword declares a given variable name as a local variable whose contents are available only to the current invocation of this particular 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.
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
.