Link Search Menu Expand Document

6.2 Creating an array object

The array object is created using the following syntax.

ObjectType [: DataType] ObjectName [n]・ ・ ・[1]
var variable name = new ObjectType [n]・ ・ ・[2]

In the case of the format of [1], the object that executed this program is connected to the hierarchical structure that becomes the parent object, and the object with the name specified by ObjectName is generated.

[: DataType] is an optional option that specifies the data attributes of the object.

Example

TextBox: Number b [2];

Generates an array of text input fields as numeric data.

In the case of the format of [2], the reference of the generated array object is stored in the var variable. In this case, the object will have no unique name and will be accessed by variable name. Variables are not objects, so their names may change depending on the situation.

Example

var text = new String [2];
var sample = text;

In this example, the String array object can be referenced by the name of text or sample . Both point to the same instance in the String array object reference. therefore,

text [0] .value = "sample2";
MessageBox (sample [0]);

Then, “sample2” will be displayed by MessageBox .