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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:54:02+00:00 2026-05-30T00:54:02+00:00

i have this full code: program List; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, Generics.Collections;

  • 0

i have this full code:

program List;

{$APPTYPE CONSOLE}

{$R *.res}

uses  System.SysUtils,   
      Generics.Collections;

type   
  TMySubList = TList<Integer>;   
  TMyList = TObjectList<TMySubList>; 

var   
  iIndex1, iIndex2: Integer;   
  MyList: TMyList;   
  MySubList: TMySubList; 

begin

 try
    { TODO -oUser -cConsole Main : Insert code here }

    MyList := TMyList.Create;
    try

      for iIndex1 := 1 to 10 do
      begin
        MySubList := TList<Integer>.Create;
        if MyList.Count <> 0 then MySubList :=  MyList.Last;
        MySubList.Add(iIndex1);
        MyList.Add(MySubList);
      end;

      for iIndex1 := 0 to pred(MyList.Count) do
      begin
        for iIndex2 := 0 to pred(MyList[iIndex1].Count) do write(MyList[iIndex1][iindex2]:5);
        writeln;
      end;

    finally
      MyList.Free;
    end;

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

  Readln;

end.

As output i should to have something as:

 1                                   // MyList[0]
 1  2                                // MyList[1]
 1  2  3                             // MyList[2]
 1  2  3  4                          // MyList[3]
 1  2  3  4  5                       // MyList[4]
 1  2  3  4  5  6                    // MyList[5]
 1  2  3  4  5  6  7                 // MyList[6]
 1  2  3  4  5  6  7  8              // MyList[7]
 1  2  3  4  5  6  7  8  9           // MyList[8]
 1  2  3  4  5  6  7  8  9  10       // MyList[9]

But i have this result:

 1  2  3  4  5  6  7  8  9  10       // MyList[0]
 1  2  3  4  5  6  7  8  9  10       // MyList[1]
 1  2  3  4  5  6  7  8  9  10       // MyList[2]
 1  2  3  4  5  6  7  8  9  10       // MyList[3]
 1  2  3  4  5  6  7  8  9  10       // MyList[4]
 1  2  3  4  5  6  7  8  9  10       // MyList[5]
 1  2  3  4  5  6  7  8  9  10       // MyList[6]
 1  2  3  4  5  6  7  8  9  10       // MyList[7]
 1  2  3  4  5  6  7  8  9  10       // MyList[8]
 1  2  3  4  5  6  7  8  9  10       // MyList[9]

With this error to end: EInvalidPointer: Invalid Pointer Operation.
The code is much simple but not understand where i mistake, or what i forget to add to it, for have the output that i want.
Thanks again for who help me to solve this problem, very much

  • 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-30T00:54:03+00:00Added an answer on May 30, 2026 at 12:54 am

    You’re creating a new instance of MySubList and then almost always overwriting it with a pointer to an existing list which you then add a new item to. Instead you need to copy the items individually from the previous list into the new list:

      for iIndex1 := 1 to 10 do
      begin
        MySubList := TList<Integer>.Create;
        if MyList.Count <> 0 then begin
          for iIndex2 := 0 to MyList.Last.Count-1 do
            MySubList.Add(MyList.Last[iIndex2]);
        end;
        MySubList.Add(iIndex1);
        MyList.Add(MySubList);
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a full list that populates a UITableView . This I want to
i have this function to return the full directory tree : function getDirectory( $path
I'm using Kohana 3, which has full support for Unicode. I have this as
I have a database full of text fields that look like this: (paragraph of
I have a table which is full of arbitrarily formatted phone numbers, like this
I have set up the full-text search functionality in SQL Server 2008 express. This
I have an element like this: <span class=tool_tip title=The full title>The ful&#8230;</span> This seems
I have a simple app with a full screen UIWebView. This contains HTML generated
I'm probably doing this all wrong. I have a text file full of data
I have this code in jQuery, that I want to reimplement with the prototype

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.