定义数组常量,且数组是记录类型,还且记录类型中包含动态数组!这样的常量如何定义?记录类型如下:
TLerver = record
UnitName: String;
Lerver: array of String; //是不定长的!
end;该如何定义呢?:const
ThisLerver: array[0..9] of TLerver = (
? ? ? ? ? ? ? ? ? ? ? ? ?
)
TLerver = record
UnitName: String;
Lerver: array of String; //是不定长的!
end;该如何定义呢?:const
ThisLerver: array[0..9] of TLerver = (
? ? ? ? ? ? ? ? ? ? ? ? ?
)
记录、集合的初始化
Type TTest = RecordID: IntegerItem: word;end;记录初始化:constATest:TTest=(Id:0;Item:0);下面是一个复杂的记录的初始化:TGUID = packed recordD1: LongWord;D2: Word;D3: Word;D4: array[0..7] of Byte;end;POLIT_GUID: TGUID = (D1:10;D2:10;D3:10;D4:(1,2,3,4,5,6,7,8));数组初始化:TTestA = RecordItemA: String;ItemB: String;ItemC: Integer;end;Type Test = RecordID: IntegerItem: TTestA;end;ConstFirst: Array [0 .. 2] of TTestA = (//该如何写这段初始化);Secord:array [0..2] of Test=(///初始化代码如何写?);回答:集合的初始化必须明确指定每一个字段的名称和值,并且各个字段之间用;分隔。First: array[0..1] of TTestA = ((ItemA: '0 ItemA String'; ItemB: 'ItemB String'; ItemC: 10),(ItemA: '1 ItemA String'; ItemB: '1 ItemB String'; ItemC: 20),());Secord: array[0..1] of Test = ((ID: 10; Item: (ItemA: 'Test 0 ItemA'; ItemB: 'Test 0 ItemB'; ItemC: 10)),(ID: 20; Item: (ItemA: 'Test 1 ItemA'; ItemB: 'Test 1 ItemB'; ItemC: 20)),());
type
TMyData = record
ID,
VAL: String;
end; TMyList = array [0..1] of TMyData;const
List: TMyList = ((ID:'1';VAL:'1'),(ID:'2';VAL:'2'));
beginend;