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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:51:48+00:00 2026-05-10T17:51:48+00:00

I am using a multi-dimensional dynamic array in delphi and am trying to figure

  • 0

I am using a multi-dimensional dynamic array in delphi and am trying to figure this out:

I have 2 seperate values for the first index and second index that are totally seperate of each other.

As new values come I want to grow the array if that new value is outside of either bound.

For new values x, y

I check:

if Length(List) < (x + 1) then    SetLength(List, x + 1); if Length(List[0]) < (y + 1) then    SetLength(List, Length(List), y + 1); 

Is this the correct way to do this or is there a better way to grow the array as needed?

  • 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. 2026-05-10T17:51:49+00:00Added an answer on May 10, 2026 at 5:51 pm

    I think you forgot to use the second index on the second dimension;

    Your code should probably read like this :

    if Length(List) < (x + 1) then    SetLength(List, x + 1); if Length(List[x]) < (y + 1) then    SetLength(List[x], y + 1); 

    Note the use of ‘x’ as the first dimension index when growing the second dimension.

    One caution though :

    You should be aware of the fact that Delphi uses reference-counting on dynamic arrays too (just like how it’s done with AnsiString). Because of this, growing the array like above will work, but any other reference to it will still have the old copy of it!

    The only way around this, is keeping track of these array’s with one extra level of indirection – ie. : Use a pointer to the dynamic array (which is also a pointer in itself, but that’s okay).

    Also note that any of those ‘external’ pointers should be updated in any situation that the address of the dynamic array could change, as when growing/shrinking it using SetLength().

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

Sidebar

Ask A Question

Stats

  • Questions 87k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ok, let's go through your questions. 1) Vaguely, yes. You… May 11, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer The new Vector class is a form of generics that… May 11, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer Java introduced in R6 update 10 a pipeline that renders… May 11, 2026 at 5:38 pm

Related Questions

I am trying to create a multi dimensional array using this syntax: $x[1] =
I have CSV data loaded into a multidimensional array. In this way each row
I'm in a basic programming class, and everything is done in pseudo code. My
I am looking for a way to store a large variable number of matrixes

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.