As we mentioned above, it is possible to declare arrays of components and attributes. A component declarator for a component array takes one of the following forms:
Identifier DimExprs Identifier DimExprs ConstraintBlock Identifier DimExprs { ConstraintBlocks }where DimExprs, ConstraintBlock and ConstraintBlocks are defined as follow:
DimExprs: '['Expression']'...'['Expression']' Constraints: Constraint;...,Constraint ConstraintBlock: { Constraints } ConstraintBlocks: ConstraintBlock,...,ConstraintBlockWhen there is only one constraint block following DimExprs, the constraints apply to all the array elements. In contrast, when there are multiple constraint blocks following DimExprs (the number of the constraint blocks must be the same as the size of the first dimension), the first constraint block applies to the first array element, the second one applies to the second array element, and so on.
An attribute declarator for an attribute array has the following form:
Identifier DimExprs Identifier DimExprs in D Identifier DimExprs R ExpressionThe domain constraint and the arithmetic constraint following DimExprs apply to all the array elements.
The following shows three examples:
component Button bts[10]{width == 30; height==30}; component Label lbs[3]{{text == "zero"}, {text == "one"}, {text == "two"}}; attribute int qs[10] in 0..9;The first declaration declares ten buttons bts[0],...,bts[9] that have the same size
Elements of component and attribute arrays can be referenced in the same way as array elements in Java.