Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with Dynamic Arrays.

Posted on 1998-09-26
2
Medium Priority
?
156 Views
Last Modified: 2010-04-06
Could someone please give me an example of how to reallocate the size of a dynamic array without losing the items currently in the array. What I need to do is declare a dynamic array of records and then increase the size of the array by one every time I need to add a new record.

Thanks

BTW, what's up with the Delphi Debugger? I'm new to Delphi(from VB) and was wondering why the debugger doesn't give more info... like the line that caused the AccessViolation or a least a description of what happened. Do I have something setup wrong or have I found the first drawback to my switch from VB? This might be normal for a non-interpreted language... I'm not sure. But I'll tell you that CPU View doesn't help me at all =)
0
Comment
Question by:Karma121397
[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
2 Comments
 
LVL 2

Expert Comment

by:omsec
ID: 1340868
i think that's like in Basic. If your Array actually contains 50
Elements for example, you can't go below these 50 if you don't want to lose values in the End of the Array.

for more info see Delphi 4 Help

CONTENTS - WHAT'S NEW IN DELPHI 4 - DYNAMIC ARRAYS
0
 
LVL 20

Accepted Solution

by:
Madshi earned 400 total points
ID: 1340869
Karma,

var testRec : array of record
                         str: string;
                         int: integer;
                       end;

SetLength(testRec,1);
with testRec[0] do begin str:='test'; int:=777 end;
SetLength(testRec,2);
with testRec[1] do begin str:='test2'; int:=778 end;
if (testRec[0].str<>'test') or (testRec[0].int<>777) then
  raise Exception.Create('Aaaaaaahhhrggg... This should not happen!');

Of course, if you now call "SetLength(testRec,1)" the second record (and it's content) is lost. That's what omsec means. But that was not your question, I think...

Normally Delphi should show you the line where the exception happened. Go to menu->project->options/compiler/debug. Make sure you check all checkboxes that Delphi needs to find the exception location. I don't know the exact setting you need. (I've the german version, so the names of the checkboxes differ.)
In the editor you should see a small blue dot/circle before each line that contains code and that is not linked out of the executable.

Regards, Madshi.
0

Featured Post

Independent Software Vendors: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

618 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