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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:35:45+00:00 2026-05-31T09:35:45+00:00

AFAIK we cannot assign directly values to record members if the said record is

  • 0

AFAIK we cannot assign directly values to record members if the said record is in a generic structure.

For example, having:

type

TMyRec = record
  Width: integer;
  Height: integer;
end;

var
  myList: TList<TMyRec>;


...
  myList[888].Width:=1000; //ERROR here: Left side cannot be assigned.
...

Till now, I used a temporary variable in order to overcome this:

var
  ...
  temp: TMyRec;
  ...

begin
  ...
  temp:=myList[999];
  temp.Width:=1000;
  myList[999]:=temp;
  ...
end;

Ugly, slow, but works. But now I want to add to TMyRec a dynamic array:

type
  TMyRec = record
    Width: integer;
    Height: integer;
    Points: array or TPoint;
  end;

…or any other data structure which can became big so copying back and forth in a temporary variable isn’t a feasible option.

The question is: How to change a member of a record when this record is in a generic structure without needing to copy it in a temporary var?

TIA for your feedback

  • 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-31T09:35:46+00:00Added an answer on May 31, 2026 at 9:35 am

    A dynamic array variable is just a reference to the array. It’s stored in the record as a single pointer. So you can continue with your current approach without any excessive copying. Copying an element to a temporary variable only copies a reference to the array and does not copy the array’s contents. And even better, if you are assigning to the array’s items then you don’t need the copy at all. You can write:

    myList[666].Points[0] := ...
    

    If you do have a record that really is big then you would be better using a class rather than a record. Because an instance of a class is a reference, the same argument as above applies. For this approach you may prefer TObjectList<> to TList<>. The advantage of TObjectList<> is that you can set the OwnsObjects property to True and let the list be in charge of destroying its members.

    You could then write

    var
      myList: TObjectList<TMyClass>
    ....
    myList[666].SomeProp := NewValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because
AFAIK ROWID in Oracle represents physical location of a record in appropriate datafile. In
AFAIK one of the objectives of Stack Overflow is to make sure anyone can
AFAIK, extern keyword should be used for declaration and no value can be associated
AFAIK, for pointers/references static_cast, if a class definition is not visible to compiler at
Afaik, you can change/manipulate browser settings in Mozilla/Netscape browsers. For Instance netscape.security.PrivilegeManager.enablePrivilege('someprivilege'); Of course
The program below prints: my name is:null my name is:null Someclass static init AFAIK
In this small example, c++ forgets size of an array, passed to a constructor.
As explained, for example, here , there are 3 main uses for the void
I have ControlA which accepts an IInterfaceB which has a property of type List<unknownType>

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.