Solved

adjust the size of a dynamic array

Posted on 2008-10-27
6
234 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 126
Delphi cmd execution 6 55
Android studio getdrawable(int) is deprecated 4 39
how to update exe applicatio from internet ? 6 67
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

911 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

16 Experts available now in Live!

Get 1:1 Help Now