Solved

adjust the size of a dynamic array

Posted on 2008-10-27
6
237 Views
Last Modified: 2013-11-23
why can't I do:
1)


TPointList = array of TPoint

function(...)  :  TPointList
begin
     setlength (myPoint, n)

    result :=  myPoint;
end;


2)  function  newPoints (var  aPointList)
    begin
      setlength aPointList, n)
     ......
   end;

both functions seem to be mega buggy ....
0
Comment
Question by:BdLm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 22815512
what kind of bugs do you encounter?
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 125 total points
ID: 22816548
don't forget, that unless you state otherwise, your aray will be zero based
ie. the first element will be [0], the 2nd will be [1]
so when you do
SetLength(myarray, 2)
you can use elements 0, and 1, NOT 2

also your sample 2 has a typo (mising "("  )

2)  function  newPoints (var  aPointList)
    begin
      setlength(aPointList, n)
     ......
   end;
0
 
LVL 8

Author Comment

by:BdLm
ID: 22817340
I made a sampler app, everthing seem to be fine, now in the
real world app i just made an array with 10  element, the first 4  points showed the corecct data, the others are (0,0) points
 
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Assisted Solution

by:MerijnB
MerijnB earned 125 total points
ID: 22817349
sounds like a bug where you overwrite memory or something.
0
 
LVL 8

Author Comment

by:BdLm
ID: 22819499
found the bug,
wrong loop construction while copying the data to the array .-(
0
 
LVL 8

Accepted Solution

by:
BdLm earned 0 total points
ID: 22819524
proposen to delete tius question bur award you the points ....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to renew a Delphi rad-studio licence? 5 77
creating threads in delphi 1 166
Delphi: sending SMS on android platform 1 69
Microsoft Access 97 and Delphi XE2 9 74
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question