PDA

View Full Version : help needed : Typed CONSTANTs



sunscarab
19-05-2017, 11:34 AM
My question is, how can i set up a constant of a special type with several values ?

<code>
TYPE
TDesc = record
a,b,c : dword;
end;

// typed constant declaration identifier : type = typed constant
CONST
abc : TDesc = ( a:dword=10
b:dword=11,
c:dword=12 );
</code>

AthenaOfDelphi
19-05-2017, 01:52 PM
Do something like this:-



Type
TMyType = record
name: string;
data1: integer;
data2: string;
end;

Const
MY_DATA : array[0..1] of TMyType = (
(name:'Fred'; data1:10; data2:'Favourite colour'),
(name:'Borris'; data1:16; data2:'Mother''s maiden name')
);

sunscarab
19-05-2017, 03:21 PM
thanks a lot! :-)

NOUR
17-01-2019, 06:17 PM
Hi,

After all this time using Pascal, I have never created a constant array or a constant array of records Mini Militia (https://www.minimilitia.mobi/) App Lock (https://www.applock.ooo/) 7Zip (https://www.7zip.vip/). Its good to know that PAscal offers this syntax, who knows ? May be I will need something like that in the near future.