Resizing an array multiple times

Please discuss general Delphi programming topics here.

Resizing an array multiple times

Postby Wardlow » June 28th, 2007, 12:40 am

Here's an example of how I'm resizing an array:
SetLength(High_, size); SetLength(Low_, size);

Is it possible to re size this array later on the program where I might have a line of code
SetLength(High_, size2); SetLength(Low_, size2); ???


Thanks
Wardlow
Wardlow
Junior Member
Junior Member
 
Posts: 38
Joined: May 31st, 2007, 10:08 pm

Postby Johnny_Bit » June 28th, 2007, 4:27 am

Why dont you try it?
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Wardlow » June 28th, 2007, 4:31 am

I did I get an error
Wardlow
Junior Member
Junior Member
 
Posts: 38
Joined: May 31st, 2007, 10:08 pm

Postby Wardlow » June 28th, 2007, 4:46 am

uh oh, you're right. It worked sorry about that ridiclous post
Wardlow
Junior Member
Junior Member
 
Posts: 38
Joined: May 31st, 2007, 10:08 pm

Postby Wardlow » June 28th, 2007, 8:09 pm

One more ? about this.

Code: Select all
if count = 0  then
SetLength(MyArray, size);
MyArray[i] := x;

if count = 1 then
SetLength(MyArray, size2);


I'm having this MyArray go through a loop, when the loop is over I use the function SetLength(MyArray, x). Does this Reset MyArray to 0?
Wardlow
Junior Member
Junior Member
 
Posts: 38
Joined: May 31st, 2007, 10:08 pm

Postby Johnny_Bit » June 29th, 2007, 7:06 am

No, if new length is not 0 then data in your array should be untouched.
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron