NetRexx includes the concept of arrays (ordered references to objects of the same type, indexed by integers). In the Java environment, arrays are constrained to be fixed size, and are indexed by integers with the first item in the array having the index 0.
Individual objects of class Rexx also support an associative array lookup mechanism (where the index is not constrained to be just integers), equivalent to Rexx stems; this is described in the next section.
Arrays are indicated in NetRexx syntax by the use of square brackets, [], and are constructed just like other objects except that brackets are used instead of parentheses:
arg=String[4] -- makes an array of four Strings i=int[3] -- makes an array of three 'int's
Brackets are used conventionally for referring to a member of an array:
i[2]=3 -- sets the '2'-indexed value of 'i' j=i[2] -- sets 'j' to the '2'-indexed value of 'i'
Regular multiple-dimensioned arrays may be constructed and referenced by using multiple expressions within the brackets, separated by commas:
i=int[2,3] -- makes a 2x3 array of 'int' type objects i[2,2]=3 -- sets the '2,2'-indexed value of 'i' j=i[2,2] -- sets 'j' to the '2,2'-indexed value of 'i'
The type of a variable that refers to an array can be set (declared) by assignment of the type with array notation that indicates the dimension of an array without an initial size or sizes:
k=int[] -- one-dimensional array of 'int' objects m=float[,,] -- three-dimensional array of 'float' objects
The same syntax is also used when describing an array type in the arguments of a METHOD instruction or when converting types.
[ previous section | contents | next section ]
From 'netrexx.doc', version 0.75.
Copyright(c) IBM Corporation, 1996. All rights reserved. ©