[fpc-pascal] Having trouble defining an initialized constant correctly
Cox, Stuart TRAN:EX
Stuart.Cox at gov.bc.ca
Fri Dec 17 23:33:20 CET 2010
Please excuse me if I've posted this request to the wrong list. I
really did spend some time in trying to find a FPC list for simple
coding questions. Sorry.
I have a set of record types defined and want to create an initialized
constant and an array constant with values. Occasionally I find that I
just cannot get the structure of the constants written properly and the
compiler whines at me until I throw my hands in the air. I'd really
appreciate it if someone could show me what I'm not able to see for
myself.
{The types are:}
Type
TFloat = Double;
TPoint2D = record
x,
y:TFloat;
end;
TSegment2D = array [1..2] of TPoint2D;
TSlabel = string[5];
TSegLabID = record
slabel : TSlabel;
segmentNo : integer;
end;
TSrecord = record
sSegLabID : TSegLabID;
segment : TSegment2D;
end;
TLSegment = record
Srecord : TSrecord;
trueLP : TPoint2D;
end;
TexistingLines5 = array[0..4] of TLSegment;
{Then the hard part:}
Const
{ one wee little one }
LSegmentNull : TLSegment = (Srecord:(sSegLabID:(sLabel:'';
segmentNo:maxlongint)
);
segment:((x:maxlongint;y:maxlongint),
(x:maxlongint;y:maxlongint)));
trueLP:(x:maxlongint;y:maxlongint));
{ an array of five of the little blighters }
CexistingLines : TexistingLines5= (
(Srecord:(sSegLabID:(sLabel:'0';segmentNo:0));segment:((x:0.5;y:0.5),(x:
3.5;y:1.7));trueLP:(x:0.5;y:0.5)),
(Srecord:(sSegLabID:(sLabel:'1';segmentNo:1));segment:((x:1.0;y:4.0),(x:
5.8;y:2.8));trueLP:(x:1.0;y:4.0)),
(Srecord:(sSegLabID:(sLabel:'2';segmentNo:2));segment:((x:1.5;y:3.0),(x:
6.2;y:2.4));trueLP:(x:1.5;y:3.0)),
(Srecord:(sSegLabID:(sLabel:'3';segmentNo:3));segment:((x:2.3;y:4.3),(x:
6.8;y:4.7));trueLP:(x:2.3;y:4.3)),
(Srecord:(sSegLabID:(sLabel:'4';segmentNo:4));segment:((x:2.5;y:0.3),(x:
6.8;y:4.7));trueLP:(x:2.5;y:0.3))
);
Can anyone save me from my misery?
Stu Cox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20101217/2a46e5ec/attachment.html>
More information about the fpc-pascal
mailing list