RTTI Delphi Create as TValue an n-dimensional matrix.

Posted by user558126 on Stack Overflow See other posts from Stack Overflow or by user558126
Published on 2010-12-30T13:33:43Z Indexed on 2010/12/30 13:53 UTC
Read the original article Hit count: 243

Filed under:
|
|
|
|

Good day, I had tried to make recurrent function to return a TValue as a n-dimensional. matrix(2D, 3D, 4D...)

for example, this procedure will show a n-dimensional matrix(it will list all elements from a n-dimensional matrix as TValue variable):

Procedure Show(X:TValue);
var i:integer;
begin
   if x.IsArray then
   begin
      for i:=0 to x.GetArrayLength-1 do
          show(x.GetArrayElement(i));
      writeln;
   end else
   write(x.ToString,' ');

end;

I don't understand how to create a function to create from a TValue an n-dimensional matrix. For example i need a Function CreateDynArray(Dimensions:array of integer; Kind:TTypeKind):TValue; and the function will return a TValue which is a dynamic array how contain the dimenssions for example:

Return=CreateDynArray([2,3],tkInteger); will return a TValue as tkDynArray and if i will show(Return) will list

0 0 0
0 0 0

Thank you very much, and have a nice day!

© Stack Overflow or respective owner

Related posts about delphi

Related posts about matrix