Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610718
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:47:14+00:00 2026-05-18T21:47:14+00:00

I have a question. I am a newbie with Run Time Type Information from

  • 0

I have a question. I am a newbie with Run Time Type Information from Delphi 2010. I need to set length to a dynamic array into a TValue. You can see the code.

Type TMyArray = array of integer;
TMyClass = class
publihed
function Do:TMyArray;
end;

function TMyClass.Do:TMyArray;
begin
SetLength(Result,5);
for i:=0 to 4 Result[i]=3;
end;
.......
.......
......
y:TValue;
Param:array of TValue;
.........
y=Methods[i].Invoke(Obj,Param);//delphi give me a DynArray type kind, is working, Param works to any functions.

if Method[i].ReturnType.TypeKind = tkDynArray then//is working...
begin
    I want to set length for y to 10000//i don't know how to write.
end;

I don’t like Generics Collections.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:47:14+00:00Added an answer on May 18, 2026 at 9:47 pm

    TValue wasn’t designed for arbitrary manipulation of its contents (it would have more helpers for e.g. setting record fields etc. if so), but rather for transporting values between concrete static types and dynamic RTTI. In this respect, TValue.SetArrayElement is an anomaly, and in hindsight, perhaps should not have been included. However, what you ask is possible:

    uses Rtti;
    
    type
      TMyArray = array of Integer;
      TMyClass = class
        function Go: TMyArray;
      end;
    
    function TMyClass.Go: TMyArray;
    var
      i: Integer;
    begin
      SetLength(Result, 5);
      for i := 0 to 4 do
        Result[i] := 3;
    end;
    
    procedure P;
    var
      ctx: TRttiContext;
      v: TValue;
      len: Longint;
      i: Integer;
    begin
      v := ctx.GetType(TMyClass).GetMethod('Go').Invoke(TMyClass.Create, []);
      Writeln(v.ToString);
      len := 10;
      DynArraySetLength(PPointer(v.GetReferenceToRawData)^, v.TypeInfo, 1, @len);
      Writeln(v.GetArrayLength);
      for i := 0 to v.GetArrayLength - 1 do
        Writeln(v.GetArrayElement(i).ToString);
    end;
    
    begin
      P;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a newbie question. I need help on separating a text file into
I have another newbie question; lets say I have a set of numbers graph_val
I have a newbie question regarding when to release the elements of a NSArray.
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
Swing newbie question... I have a system where there is a large number of
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Newbie question... The objective: I intend to have an HTML text input field as
MVC newbie question re binders. Supposing I have two strongly typed partial actions that
quick and very basic newbie question. If i have list of dictionaries looking like
This is a real newbie question. I have simple app that selects a picture

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.