SRL Archive - Lape

TCardinalArray problems


riwu

2014-09-14 07:28:12


I could declare single length as Cardinal then introduce identical type methods (eg. http://paste.villavu.com/show/6352/) to solve the problem but fixing it would make it more convenient.


Also is it possible to declare array constants?

@nielsie95

nielsie95

2014-09-14 09:56:51

Constant arrays like this are always interpreted as static arrays (arrays defined with constant length). The second cast goes wrong because SizeOf(array[0..0] of Cardinal) equals SizeOf(TCardinalArray) (which equals SizeOf(Pointer)). You can solve this with an assignment as follows:


var
a: TCardinalArray = [1, 2, 3];
b: TCardinalArray = [1];