My plan is to make a function that retrieves the highest element of an object, so to speak, the upper range of an array.In other words,I'm trying to get the the code of the function High().
What I have tried so far:
function High2(var X):integer;
begin
Result:=Pbyte(Cardinal(@X)-1)^-1;
end;
The function above should read the value(length) before the position of the first element in the object(array/string) and return it decreased by 1.However It doesn't retrieve correct results neither on static nor dynamic array type.
How do I recreate the High() function in Pascal?