0

Is it possible to mix static and dynamic arrays when creating a multidimensional array and then use that to define a const of that type. The compiler does not appear to have an issue with the following so I assume its legal to mix dynamic and static arrays like this...

TSoftKeyBase = (skEmptyCommandLine, skChannelsSelected);
TSoftKeySet = array of array of String;
TSoftKeys = array[TSoftKeyBase] of TSoftKeySet;

When I try to define a const for this array I keep getting "Ordinal type required" on the inner list of elements. Am I pushing beyond the scope of the language?

const
  SOFT_KEYS: TSoftKeys =
      [
        [
          ['Select Previous', 'Page',         'Close',        'SC',             'Park',             'MORE >'],
          ['Output',          'FX',           'Macro',        'Select Active',  'Select Changed',   'MORE >'],
          ['Cue List',        'Re Cue List',  'Load',         'Inclusive Mode', 'Active Sel Mode',  'MORE >'],
          ['If',              'View',         'Scroll To',    '',               '',                 'MORE >']
        ],
        [
          ['Select Previous', 'Last',         'Next',         'Clear Selection','Park',             'MORE >'],
          ['Down %',          'Up %',         'Home',         'Select Active',  'Select Changed',   'MORE >'],
          ['Virtual DSC',     'HiLight',      'LoLight',      'Fan',            'Offset',           'MORE >'],
          ['',                '',             '',             '',               '@ ATTs',           'MORE >']
        ]
      ];

1 Answer 1

2

You need to use normal parentheses at the outer-most level (array[TSoftKeyBase]), because it is a static array (and not a dynamic array or a set).

const
  SOFT_KEYS: TSoftKeys =
      (
        [
          ['Select Previous', 'Page',         'Close',        'SC',             'Park',             'MORE >'],
          ['Output',          'FX',           'Macro',        'Select Active',  'Select Changed',   'MORE >'],
          ['Cue List',        'Re Cue List',  'Load',         'Inclusive Mode', 'Active Sel Mode',  'MORE >'],
          ['If',              'View',         'Scroll To',    '',               '',                 'MORE >']
        ],
        [
          ['Select Previous', 'Last',         'Next',         'Clear Selection','Park',             'MORE >'],
          ['Down %',          'Up %',         'Home',         'Select Active',  'Select Changed',   'MORE >'],
          ['Virtual DSC',     'HiLight',      'LoLight',      'Fan',            'Offset',           'MORE >'],
          ['',                '',             '',             '',               '@ ATTs',           'MORE >']
        ]
      );

Simpler examples:

type
  TTest = array[0..2] of Integer; // static array

const
  Data: TTest = (10, 20, 30);

and

type
  TTest = array of Integer; // dynamic array

const
  Data: TTest = [10, 20, 30];

and

type
  TTest = set of Byte; // set

const
  Data: TTest = [10, 20, 30];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.