我正在尝试创建一个复杂的结构来包含在执行过程中不应更改的程序数据。我有以下代码,它不起作用,但它传达了我正在尝试做的事情的要点:
type
TTestFieldProperties = record
FieldType: Integer;
end;
TTestFieldPropertyArray = array of TTestFieldProperties;
TTestTypeProperties = record
TestType: Integer;
TestFieldProperties: TTestFieldPropertyArray;
end;
const
TestTypeProperties: array [0..1] of TTestTypeProperties = (
(
TestType: 2361;
TestFieldProperties: nil
), (
TestType: 3526;
TestFieldProperties: /*array [0..1] of TTestFieldProperty???*/
(
(
FieldType: 3
), (
FieldType: 7
)
)
)
);
在此示例中,我有一个名为 TTestTypeProperties 记录的记录,其中包含 TTestFieldProperty 记录数组。我正在尝试创建一个定义 TTestTypeProperties 记录数组的常量结构。所以本质上,一个记录数组包含另一个记录数组。
有更好的方法来做我想做的事吗?
上面的代码无法编译,因为我不知道如何处理 TestFieldProperties 字段。是否需要边界定义?
数组的大小必须在声明时已知。
例如,这是有效的:
TTestFieldProperties = record
FieldType: Integer;
end;
TTestFieldPropertyArray = array [0..1] of TTestFieldProperties;
(* fixed array size here *)
TTestTypeProperties = record
TestType: Integer;
TestFieldProperties: TTestFieldPropertyArray;
end;
const
TestTypeProperties: array [0..1] of TTestTypeProperties = (
(
TestType: 2361;
TestFieldProperties: (*array [0..1] of TTestFieldProperty???*)
(
(FieldType: 3), (FieldType: 7)
)
), (
TestType: 3526;
TestFieldProperties: (*array [0..1] of TTestFieldProperty???*)
(
(FieldType: 3), (FieldType: 7)
)
)
);