[fpc-pascal] Static Initialisation of Arrays
Paul Michell
Paul at InterfaceDesign.co.uk
Mon Jun 28 11:17:10 CEST 2010
Hello All,
I am working on a program that requires some simple embedded array data.
I can get the following to compile:
Type
TCharacterAreaData = Record
Code: Integer;
Name: String;
Geometry: Array [0..3] Of Single;
End;
Const
Area1: TCharacterAreaData = (Code: 1;
Name: 'Border Moors and Forests';
Geometry: (1,2,3,4));
My problem is the number of elements in the Geometry Array is variable.
So if I try this:
Type
TCharacterAreaData = Record
Code: Integer;
Name: String;
Geometry: Array Of Single;
End;
Const
Area1: TCharacterAreaData = (Code: 1;
Name: 'Border Moors and Forests';
Geometry: (1,2,3,4));
Area2: TCharacterAreaData = (Code: 2;
Name: 'Bowland Fells';
Geometry: (1,2,3,4,5,6));
I get this syntax error:
Areas.pas(46,42) Fatal: Syntax error, "NIL" expected but "(" found
I realise that 'Array Of Single' declares a dynamic array, but is there
any equivalent syntax for static data arrays in the same way that
strings litterals are in effect, variable length static declarations.
Thanks in advance,
Paul Michell
P.S. I'm using FPC 2.4.1 i386-win32-win32/win64
More information about the fpc-pascal
mailing list