Page 1 of 1

Dynamic Arrays

PostPosted: July 23rd, 2008, 3:03 pm
by Sezar
Hi everybody...
I've used a dynamic array of variant type,The First element of this array has a string ,when I insert a numeric value in the second index, the order will be changed...

Code: Select all
var
 DynArr:Array of Variant;
 i:Integer;
begin
SetLength(DynArr,4);
DynArr[0]:='Some String';
DynArr[1]:=10;
// now => DynArr[0]=10 ; DynArr[1]='String'
end;

PostPosted: July 23rd, 2008, 4:57 pm
by Kambiz
Which version of Delphi? It might be a compiler bug.

I checked it out on Delphi 7, no bug of course.

Dynamic Arrays

PostPosted: July 26th, 2008, 4:29 am
by Sezar
Hello...
thanks for you reply,but I use delphi7...

PostPosted: August 19th, 2008, 7:09 am
by BlackJack
How do you know the order changed?
I checked your code out on my computer(ver Delphi 7),it's no problem.
use this code to have a checked
Code: Select all
var
 DynArr:Array of Variant;
 i:Integer;
begin
SetLength(DynArr,4);
DynArr[0]:='Some String';
DynArr[1]:=10;
// we want to see that: now => DynArr[0]=10 ; DynArr[1]='String'
// but it does not all happen~~~,it's normal~~~.
ShowMessage(DynArr[0]);
ShowMessage(DynArr[1]);
//DynArr[2]:='30';
end;