Array Extension¶
Extension introduced in TethysL 1.8.0 (2019)
Declaration¶
An array declaration defines a sequence of arguments (or outputs) sharing a base name.
It consists of the name (e.g., Lat) followed by a range of indices in brackets ([1..4]),
then = and the value:
This is equivalent to defining Lat1, Lat2, Lat3, Lat4, and Lon1, ..., Lon4,
which are the names in the generated XML (and the ones to use, for example, when setting
the mission parameters on the vehicle).
The range limits can be numbers or constants:
const $NUM_WAYPOINTS = 10
arguments {
Lat[1..$NUM_WAYPOINTS] = NaN degree
Lon[1..$NUM_WAYPOINTS] = NaN degree
}
Values¶
The value in the declaration can be given in three ways:
-
A single expression, assigned to all the entries:
-
An explicit array, with
[ ... ], indicating the value for each entry: -
Sub-ranges, with
{ ... }, where each component has the range of indices, a colon:, and either a single expression or an explicit array for that sub-range:
A description given to an array declaration serves as the description of all the expanded elements.
Access¶
An entry is referenced with the index in brackets, typically using a macro variable:
The index is a static expression: a number, a macro variable, a constant,
or an addition/subtraction of these, e.g., Lat[$k - 1], Depth[$j + 1].
Rules¶
- A name can only be declared once. That is, multiple declarations with the same base name are not allowed, even for non-overlapping ranges; use sub-ranges instead.
- The name of an array cannot be the same as that of another argument or output,
even if not an array (e.g.,
CartridgeType[1..60]andCartridgeType).
Lint¶
The lint reports groups of definitions that could be replaced with an array declaration, along with a hint to use a constant for the upper limit: