contents   index   previous   next



global.setAttributes()

syntax:

setAttributes(variable, attributes)

where:

variable - a variable identifier, name.

 

attributes - the attribute or attributes to be set for a variable. If more than one attribute is being set, use the or operator, "|", to combine them.

 

return:

void.

 

description:

This function sets the variable attributes for the parameter variable using the parameter attributes. Variables in ScriptEase may have various attributes set that affect the behavior of variables. This function has no return.

 

The following list describes the attributes that may be set for variables. Multiple attributes may be set for variables by combining them with the or operator. For example, the flag setting READ_ONLY | DONT_ENUM sets both of these attributes for one variable.

 

DONT_DELETE
This variable may not be deleted. If the delete operator is used with a variable, nothing is done.

DONT_ENUM
This variable is not enumerated when using a for/in loop.

IMPLICIT_PARENTS
This attribute applies only to local functions and allows a scope chain to be altered based on the __parent__ property of the "this" variable. If this flag is set, if the __parent__ property is present, and if a variable is not found in the local variable context, activation object, of a function, then the parents of the "this" variable are searched backwards before searching the global object. The example below illustrates the effect of this flag.

IMPLICIT_THIS
This attribute applies only to local functions. If this flag is set, then the "this" variable is inserted into a scope chain before the activation object. For example, if variable TestVar is not found in a local variable context, activation object, the interpreter searches the current "this" variable of a function.

READ_ONLY
This variable is read-only. Any attempt to write to or change this variable fails.

see:

global.getAttributes()

 

example:

// The following fragment illustrates the use

// of setAttributes() and the behavior affected

// by the IMPLICIT_PARENTS flag.

function foo()

{

   value = 5;

}

setAttributes(foo, IMPLICIT_PARENTS)

 

var a;

a.value = 4;

var b;

b.__parent__ = a;

b.foo = foo;

b.foo();

 

// After this code is run, a.value is set to 5.

 


global.ToBoolean()