• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

adjust the size of a dynamic array

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
BdLm
Asked:
BdLm
  • 3
  • 2
3 Solutions
 
MerijnBSr. Software EngineerCommented:
what kind of bugs do you encounter?
0
 
TheRealLokiSenior DeveloperCommented:
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
 
BdLmAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
MerijnBSr. Software EngineerCommented:
sounds like a bug where you overwrite memory or something.
0
 
BdLmAuthor Commented:
found the bug,
wrong loop construction while copying the data to the array .-(
0
 
BdLmAuthor Commented:
proposen to delete tius question bur award you the points ....
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now