[pascal]
// expected result is 100 !! but its is
[/pascal]
However ptr^ := Random(100); can also place 0 within the array which would terminate length function early. Unless you manage data so there is no null inside it is more "proper" to store the length within a separate variable or possibly at the beginning of array.