Data Types

reference

Supported By

Description

The reference data type is a non-container data type that points to a variant that may or may not be a container. In string form, a reference appears as a descriptor or XION literal.

A reference is used to freely pass around a container. When an attempt is made to put a container into a variable, list, dictionary, or other container, or to pass a container as a parameter to a message or function handler, the container's contents are passed instead. In order to pass around the container itself, a reference must be created.

Script

The following example illustrates using references to change a string. In this example, we want to pass in the container last word of greeting. However, if we were to naively pass in last word of greeting, the actual last word, "Becky.", would be passed in instead. So instead, we pass in a reference.

on tweak what as reference, newValue as string
  put newValue into the referent of what
end tweak

local greeting as string
put "Hello, my name is Rebecca. But you can call me Becky." into greeting
tweak (a reference to last word of greeting), "Beckie."

See Also

a reference to, the referent of