Home > Process Behavior Procedures and Reference > Process Behavior Reference > Arrays in iGrafx

Arrays in iGrafx

Rule

Example

Array indices are enclosed in square brackets.

T.attr[0]

Every attribute has an associated one-dimensional and two-dimensional array. The example shown represents 3 distinct values.

T.x, T.x[0], T.x[0,0]

Arrays can be indexed by a string. In the example, SkillLevel is an attribute and Person1 is a textual index element in the array.

SkillLevel["Person1"]

iGrafx allows array index values to be non integers; floating point values are not truncated. The example shown stores 3 distinct values into the array x.

x[0.5]=1, x[1.0]=2, x[1.5]=3

Individual elements of an array can be of type numeric or string, as can individual array indices.

x[1,1] = 1, x[2, "two"] = "two", x["three",3] = 3, x["four","four"] = "four"

To assign an element of an array, you select an attribute within a dialog box and then begin the expression with the array index. Selecting the attribute T.x and then specifying the expression [0]=1 sets T.x[0]=1.

Selecting the attribute T.shipped within a dialog box and then specifying [0] = shipped[0] + 1 as the expression means "add 1 to the value of shipped [0]"

You cannot assign to individual array elements within the Define Attributes dialog box, but you can initialize an entire array with the ArrayInit function.

The ArrayInit, LoadCustomData, and LoadCustomDataIndex functions operate on arrays.

Related Topics

Expressions