The easiest way to create an array of structures is to use the REPLICATE function. The first parameter to REPLICATE is a reference to the structure of each element. Using the example in Examples of Structure References and assuming the STAR structure has been defined, an array containing 100 elements of the structure is created with the following statement:
cat = REPLICATE({star}, 100)
Alternatively, since the variable A contains an instance of the structure STAR, then
cat = REPLICATE(A, 100)
Or, to define the structure and an array of the structure in one step, use the following statement:
cat = REPLICATE({star, name:'', ra:0.0, dec:0.0, $
inten:FLTARR(12)}, 100)
The concepts and combinations of subscripts, subscript arrays, subscript ranges, fields, nested structures, etc., are quite general and lead to many possibilities, only a small number of which can be explained here. In general, any structures that are similar to the examples above are allowed.
It is now possible to concatenate anonymous structures as long as they have the same field sizes and types. That is to say, they do not even have to have the same field names. For example, consider this code, written in IDL 6.2.
IDL> a = {Name: 'Larry', Age: 46} IDL> b = {LastName: 'Henderson', No_of_Dogs: 4} IDL> c = [ a, b] IDL> Help, c C STRUCT = -> Array[2]
IDL> a = b
IDL> Help, a, /str
a = {LastName: 'Henderson', No_of_Dogs: 4}