^

Syntax expression^

Action The dereference operator refers to an object specified by a database address. It evaluates expression, interprets the result as the address of an Object Database cell, and yields the value of that cell.

Examples local (addr = @examples.age);
x = addr^

   » 46

This simple example shows how the dereference operator extracts the value of the address, in this case the address of the "age" cell in the "examples" table.

on triple (addrN)
addrN^ = addrN^ * 3

triple (@examples.age)
Type this script into a script window. In this example, the local script "triple" multiplies by three the value whose address is passed to it.

The example below demonstrates a more straightforward method of accomplishing the same thing, but it is interesting see how the @ and ^ operators work together here.
on triple (n)
return (n * 3)

examples.age = triple (examples.age)

typeOf (window.frontmost ()^) == tableType

   » true

Here, the value returned by window.frontmost - a string - is treated as a database address, and the type of the value at that address is compared to tableType. If the frontmost window contains a table, the result of the expression will be true.

Notes The technique shown in the second example above is generally advisable only when working with large pieces of data that reside in the database, such as binary values, in which case memory overhead may be reduced. Otherwise, the simpler approach of example

#3 is preferable.

See Also @

Discuss