How to pass structure field arrays
You can pass a structure field array to a called program. You must follow a special convention in both the call statement and in the parameter list of the called program.
Record MyRecordPart type basicRecord
10 myInt INT[5];
10 myChar CHAR(1);
end
myRecord MyRecordPart;
MyProgram program and need
to pass the structure field array rather than a single element or
the whole record, one task is to code the call statement
as follows:call MyProgram( myRecord.myInt[*] );The bracketed asterisk ([*]) means “treat the
preceding variable as a structure field array.” If you specify myRecord.myInt,
without the brackets, the program receives only the first element
in the array, as if you coded myRecord.myInt[1].
Program MyProgram type BasicProgram ( myInt INT[5]! )
end
The exclamation point indicates that the preceding variable is a structure field array rather than a dynamic array that can be re-sized in the called program. The array size and exclamation point are required after each array dimension.
Record X type BasicRecord
10 myChar CHAR(4)[2];
20 mySubChar01 char(2);
20 mySubChar02 char(2);
end
When you pass mySubChar01 or mySubChar02 array,
the fields are passed in a contiguous block of memory even though
the fields are not stored contiguously. The data must be copied, and
the extra processing takes time.
- An array is passed with [*].
- A parent or other ancestor of the array is itself an array that has more than one child.
For details on how multidimensional structure field arrays are stored, see “Arrays.”