Solved

adjust the size of a dynamic array

Posted on 2008-10-27
6
233 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now