Dynamic Arrays

Please discuss general Delphi programming topics here.

Dynamic Arrays

Postby Sezar » July 23rd, 2008, 3:03 pm

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;
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby Kambiz » July 23rd, 2008, 4:57 pm

Which version of Delphi? It might be a compiler bug.

I checked it out on Delphi 7, no bug of course.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Dynamic Arrays

Postby Sezar » July 26th, 2008, 4:29 am

Hello...
thanks for you reply,but I use delphi7...
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby BlackJack » August 19th, 2008, 7:09 am

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;
User avatar
BlackJack
Active Member
Active Member
 
Posts: 12
Joined: August 12th, 2008, 8:05 am
Location: PR China,Beijing


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 19 guests

cron