ESPL: 2-Dimensional Arrays

Q:  How do I declare a 2-dimensional dynamic array in ESPL?   A dynamic array is one where I don’t know the bounds at compile time.  It grows dynamically as new array elements are added.

A:  ESPL supports a variety of arrays, each with different characteristics.  Let me summarize the choices.

  • Multi-diminsional arrays are declared with the [ ] construct at compile time.  See the ESPL manual, topic ‘Arrays’ on page 29.
  • TArrays are single dimensional and semi-automatic in their dimension.
  • Variant arrays can be dimensioned and redimensioned, but they also are single dimensional.
  • TLists and TStringLists are single dimension.  They dynamically grow as elements are added.
  • The TStringGrid object is 2-dimensional with RowCount and ColCount properties.  And these properties can be set at run time.   The values are written and read in the string grid cells.   See this example.