Solved

adjust the size of a dynamic array

Posted on 2008-10-27
6
238 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
Industry Leaders: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

728 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