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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:36:31+00:00 2026-05-29T22:36:31+00:00

i have this problem: as i can add list to one list? i have

  • 0

i have this problem: as i can add list to one list? i have tried so, but main list return always one list, and not understand where i mistake.
The structure is this:

  PCombArray = array of Integer;
  PStatsRecord = record
    Comb: PCombArray;
    Freq: Integer;
  end;
  PStatsList = TList<PStatsRecord>;
  TStatsList = TList<PStatsList>;

Where Comb is a field that work as primary key. But here all ok. i define main list as:

var
  MainList: TStatsList;
  MySubList: PStatsList;

and create it, without problem. A procedure work for populate a subList; for esample i call this procedure as MakeSubList and assign a MySubList the list maked, then i add it to main list:

  MainList := TList<PStatsList>.Create;
  try
    MainList.Clear;    
    for index := 1 to N do // generate N subList
    begin  
      ...
      MySubList := MakeSubList(index); // contain correct sub list, no problem here
      ...
      MainList.Add(MySubList);  // add mysublist to mainlist
    end;
    writeln (mainList.count);  // return 1, and not N-1 sublist
  finally
    MainList.Free;
  end; 

Thank who help me to understand so i can solve it. Thanks again.

  • 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-29T22:36:32+00:00Added an answer on May 29, 2026 at 10:36 pm

    Your make sub list function might be wrong, or you might have confused yourself with your naming conventions which did not follow in any way the usual Delphi/Pascal naming conventions for types.

    The following code works, though.

    Note that a TList is an Object so if you want to make a List of TList be sure to use TObjectList instead of plain TList unless you like memory leaks. Your inner list is around a record type and does not need to be TObjectList, but if you changed StatsRecord to TStatsData as a TObject (class) type, you should also change to TObjectList.

    unit aUnit5;
    
    interface
    
    uses Generics.Collections;
    
    procedure Test;
    
    implementation
    
    type
          CombArray = array of Integer;
          StatsRecord = record
            Comb: CombArray;
            Freq: Integer;
          end;
          TStatsList2 = TList<StatsRecord>;
          TStatsList = TObjectList<TStatsList2>;
    
    var
          MainList: TStatsList;
          MySubList: TStatsList2;
          index:Integer;
    
    procedure Test;
    begin
    
          MainList := TStatsList.Create;
          try
            for index := 1 to 10 do // generate N subList
            begin
              MySubList := TStatsList2.Create;
              MainList.Add(MySubList);  // add mysublist to mainlist
            end;
            finally
            MainList.Free;
          end;
    end;
    
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The main problem is this one. I have 2 XMLs containing information about what
I'm quite new to hibernate and have stumbled on this problem, which I can't
I need some ideas on how I can best solve this problem. I have
I hope some of you guys can help me with this problem.... I have
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions
i have this problem: ms-access could not delete and i found a potential solution
i have this problem: starting from an empty list (0 elements) i want check
I can not figure out where my problem is but I am not able
This question looks like this one : Programmatically binding List to ListBox but as

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.