> # type > # Example = record > # id: integer; > # content: string > # end; > # var > # ExampleArray: array[1.N] of Example; > Can I initialize the array in the 'var' section? > I tried something like the following in Delphi, but it doesn't work: > ExampleArray: array[1.N] of Example = ( (1, 'example 1'), (2, 'example > 2')., (N, 'example N')); There is only one little thing you forgot (at least for BP, don't know Delphi): to declare a initialised record constant, you have to precede each field value by the field identifier, in your case: ExampleArray: ARRAY[1.N] OF Example = ( (id: 1; content: 'example 1').); Also, note the semi-colons separating the fields (instead of commas). Good luck, Remco -- Remco Vietor Department of Chemistry University of Glasgow Glasgow G12 8QQ U.K. Wed, 18 Jun 1902 08:00:00 GMT. >Hello everybody.
>How can I initialize an array of records, like ># type ># Example = record ># id: integer; ># content: string ># end; ># ># var ># ># ExampleArray: array[1.N] of Example; >Can I initialize the array in the 'var' section? >I tried something like the following in Delphi, but it doesn't work: >ExampleArray: array[1.N] of Example = ( (1, 'example 1'), (2, 'example >2')., (N, 'example N')); >Can it be done? Probably my syntax interpretation is wrong, but I have no >Pascal books at hand, and I don't want to do it in the main code, like >ExampleArray[1].id:= 1; >ExampleArray[2].content:= 'example 1'; >etc. >Any help would appreciated >TIA Hello you can initialize only CONST array and not that ones in the VAR section. The way you initialize the array above can be done only with CONST arrays. Bye Andrea Wed, 18 Jun 1902 08:00:00 GMT Page 1 of 1 [ 3 post ].