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 9129001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:38:54+00:00 2026-06-17T07:38:54+00:00

I need move the data stored in a array of bytes to a set

  • 0

I need move the data stored in a array of bytes to a set of records located in a TList, but i’m getting this error

E2197 Constant object cannot be passed as var parameter

This code reproduce the issue.

uses
  System.Generics.Collections,
  System.SysUtils;

type
  TData = record
    Age : Byte;
    Id  : Integer;
  end;

//this code is only to show the issue, for simplicity i'm filling only the first  
//element of the TList but the real code needs fill N elements from a very big array.  
var
  List : TList<TData>;
  P : array [0..1023] of byte;
begin
  try
    List:=TList<TData>.Create;
    try
      List.Count:=1;
      //here i want to move the content of the P variable to the element 0
      Move(P[0],List[0], SizeOf(TData));

    finally
      List.Free;
    end;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

How i can copy the contents of a buffer to a TList Element

  • 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-06-17T07:38:55+00:00Added an answer on June 17, 2026 at 7:38 am

    In XE2, the internal storage for TList<T> is opaque and hidden. You cannot gain access to it by normal means. All access to elements of the list are copied – references to the underlying storage are not available. So you cannot blit to it using Move. If you want a structure that you can blit to, you should consider a dynamic array, TArray<T>.

    You can always use the trick of implementing a class helper for TList<TData> that would expose the private variable FItems. That’s pretty hacky but will do what you ask.

    type
      __TListTData = TList<TData>;
      //defeat E2086 Type 'TList<T>' is not yet completely defined
    
    type
      TListTDataHelper = class helper for TList<TData>
        procedure Blit(const Source; Count: Integer);
      end;
    
    procedure TListTDataHelper.Blit(const Source; Count: Integer);
    begin
      System.Move(Source, Pointer(FItems)^, Count*SizeOf(Self[0]));
    end;
    

    I guess you might want to put some parameter checking in TListTDataHelper.Blit, but I’ll leave that to you.

    If you were using XE3, you could access the private storage of TList<T> by using the List property.

    Move(P, Pointer(List.List)^, N*SizeOf(List[0]));
    

    If you don’t need to blit and can use a for loop then do it like this:

    type
      PData = ^TData;
    var
      i: Integer;
      Ptr: PData;
    ....
    List.Count := N;
    Ptr := PData(@P);
    for i := 0 to List.Count-1 do
    begin
      List[i] := Ptr^;
      inc(Ptr);
    end;
    

    But I interpret your question that you wish to avoid this option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to (on a regular basis) move data stored in a FoxPro db
I need to move a huge amount of data from a couple tables in
I need to move the data that is a month old from a logging
I need to move math league data between two different systems, both written in
I have hierarchical data (categories) stored in a mySql database using the nested set
I have a set of data protected by 16bit checksums that I need to
I need to move a database from SQL Server 2008 to 2005, did the
I need to move a old database with an old structure to a new
I need to move large amounts of pixels on the screen on an iOS
I need to move the contents of a directory into an archive and I

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.