Name: @

Type: keyword

Syntax: @

Summary: The character @ (at sign) is used with a parameter declaration, to indicate that a reference to the parameter is passed instead of its value.

Introduced: 1.0

OS: mac,windows,linux,ios,android

Platforms: desktop,server,web,mobile

Example:
on setVariable @incomingVar -- notice the @ before the parameter name
  add 1 to incomingVar
end setVariable

Example:
on mouseUp
  put 8 into someVariable
  setVariable someVariable
  answer "someVariable is now: " & someVariable
end mouseUp

Description:
The character @ is placed before a parameter name to pass a reference to the parameter instead of its value. Pass a parameter reference when you want a handler to change a variable in the calling handler, or when you want a handler to return more than one value.

Parameters to a handler are declared on the first line of the handler. If the name of a parameter is preceded with the @ character, that parameter's value is interpreted as a variable name, rather than the value in the variable. Changing the parameter variable in the called handler changes the value of the variable in the calling handler.

In the above example, the handler setVariable takes a parameter and simply adds 1 to it. Because the parameter for the handler is declared with a leading @, the mouseUp handler passes "someVariable" by reference. This means that when the setVariable handler makes changes to the parameter, it changes the actual variable, and those changes affect all further references in the mouseUp handler to the variable. Executing this mouseUp handler displays a dialog box that says "someVariable is now: 9"

References: $ (keyword)

Tags: properties
