=

Syntax identifier = expression

Action Evaluates expression and assigns the resulting value to identifier.

Examples local (x);
x = 3 * 4

   » 12

The assignment statement causes the value of the expression "3 * 4" to be stored in the local variable "x".

scratchpad.when = clock.now ()

   » 11/11/91; 7:36 PM

In this case the expression "clock.now ()" yielded a date value, which was then assigned to the cell named "when" in the table named "scratchpad." (The "when" cell need not have already existed.)

local (x);
x = scratchpad.when

   » 11/11/91; 7:36 PM

In this case, we copy a value out of the object database and store it in a local variable.

Notes The identifier need not specify an existing database cell; the assignment statement will create an item with the given name in the specified table. If no table is specified, a new local variable is created in the code block where a local statement or a

local script definition was most recently encountered.

While assigning values to variables without declaring them can be a timesaver, it is generally bad practice; as a script becomes more complex, it quickly becomes easy to unintentionally modify a variable in an enclosing scope level.

See Also local

==

db.get

db.set

Discuss