Example: Working with structured arrays

This JavaScript example shows you how to work with structured arrays.

Note The sample "teststructarray" has the following Database Dictionary format fields:

  • id character
  • arr array
  • arr structure
  • a number
  • b character

This table has an array of type structure called "arr."

Note : To populate the elements of the field, the elements have to be populated in order.

var fvar = SCFile("teststructarray");
fvar.id="abc";
fvar.arr[2].a=10;      // Add field 'a' first
fvar.arr[2].b="Test";   // Then add field 'b'
print(fvar);
[C++ object SCFile] - teststructarray={[["abc",{{[, ]},, {[10, "Test"]}}]}

Caution Populating the fields out of order will cause an error.

For example, this will break the structure:

fvar.arr[2].b="Test";   // This will break the structure!
fvar.arr[2].a=10;