Delphi 2010 RTTI Set length dynamic array [Edit]

Good day,

I have a problem, i had searched this on google, and EDN but i didn't find a good source, or complet.

var x,y:TValue;
    a:array [0..100] of integer;
begin
   x:=TValue.From(v);
   y:=TValue.From(a);

   y.SetArrayElement(0,2);
   y.SetArrayElement(1,2);
end;

It works. because the  compiler had allocated 100*32 bits in the heap memory.
How i will procede for a dynamic array a:array of integer?
I want:
var y:TValue;
     a:array of integer;
begin
    y:=TValue.From(a);
    y.SetArrayElement(y.GetArrayLength+1);

Thank you very much and have a nice day.

Edited by: Bebe Das Xadon on Dec 29, 2010 3:22 PM

Edited by: Bebe Das Xadon on Dec 30, 2010 8:00 AM

Edited by: Bebe Das Xadon on Dec 30, 2010 8:03 AM
0
Bebe
12/30/2010 4:03:51 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

3 Replies
984 Views

Similar Articles

[PageSpeed] 45

"Bebe Das Xadon" wrote in message news:316925@forums.embarcadero.com...
>
> I have a problem, i had searched this on google, and EDN but i didn't find 
> a good source, or complet.
>
> I want:
> var y:TValue;
>     a:array of integer;
> begin
>    y:=TValue.From(a);
>    y.SetArrayElement(y.GetArrayLength+1);

You can use SetLength to set the size of a dynamic array:

    SetLength(a, 101); // 101 integers

>    y.SetArrayElement(Length(a)+1);

If you need to change the size, call SetLength again:

    SetLength(a, Length(a) + 1);

Existing values will be preserved. But if you are going to do this 
frequently, it can be a performance problem (reallocating blocks of memory 
and copying contents).

You are probably better off using a TList or TObjectList instead of arrays.

-- 
Wayne Niddery (TeamB)
"Do not consider Collectivists as 'sincere but deluded idealists.' The 
proposal to enslave some men for the sake of others is not an ideal; 
brutality is not 'idealistic,' no matter what its purpose. Do not ever say 
that the desire to 'do good' by force is a good motive. Neither power-lust 
nor stupidity are good motives." -Ayn Rand"
0
Wayne
12/30/2010 12:15:04 AM
Bebe Das Xadon wrote:

> It works. because the  compiler had allocated 100*32 bits in the heap
> memory.  How i will procede for a dynamic array a:array of integer?

Check out System.DynArraySetLength function.


ain
0
Ain
12/30/2010 11:05:04 AM
Thank you have a nice day

Edited by: Bebe Das Xadon on Dec 30, 2010 8:04 AM
0
Bebe
12/30/2010 4:04:49 PM
Reply:

Similar Artilces:

how to set array length with delphi 2010 rtti [Edit]
how to set array length in runtime ? setLength(t.GetProperty('Propertys'),3); ???? {code:delphi} unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TSubProperty = Class private Fitem2: Integer; Fitem1: String; procedure Setitem1(const Value: String); procedure Setitem2(const Value: Integer); published property item1:String read Fitem1 write Setitem1; property item2:Integer read Fitem2 write Setitem2;...

Code works in Delphi 7 but not in Delphi 2010 [Edit]
hello, i have a procedure that open's a file by passing the file name as the parameter to the executable. something like this {code} C : \ P r o g r a m F i l e s \ Da c k e r \ D r a c k e r . e x e " G : \ D E l p h i 7 \ D e l p h i 7 A p p _ l o g . t " {code} The source code is {code} procedure OpenFileWithExe var hReg: HKEY; Ret: Longint; RegDataType, RegDataSize: DWORD; CmdLine: array [0..560] of Char; Len: Integer; SInfo: TStartupInfo; PInfo: TProcessInformation; begin Ret := windows.RegOpenKeyEx(HKEY_CURRENT_USER, ...

Update Delphi 2005 to Delphi 2010, which do i need? [Edit]
Hello, we have one Delphi 2005 Professional here and want to upgrade to Delphi 2010, but we are a bit confused. Our distributor in Germany, ingram-micro offers several upgrade products: UPG DELPHI 2010 PRO - NAMED USER UPG DELPHI 2010 PRO - NAMED USER ELS UPG DELPHI 2010 PRO - NAMED USER FLEX RAD STUDIO 2010 PRO - UPG UPG RAD STUDIO 2010 PRO - NAMED ELC UPG RAD STUDIO 2010 PRO - NAMED FLEX UPG DELPHI 2010 PRO - CONCURRENT ELS UPG DELPHI 2010 PRO - CONCURRENT FLEX What do they mean exactly and which one do i need? At the moment delphi is installed on two PCs and we want to use ...

dynamical DLL loading in delphi 7 & delphi 2010
Hello, i am loading a DLL dynamical in Delphi 7 and Delphi 2010: [delphi] var hDLL: THandle; pCode: Pointer; type TProcMainEntry = function: TForm; begin hDll := 0; if FileExists(Pfad + vpeDllName) then hDLL := LoadLibrary(PChar(Pfad + vpeDllName)) else SetLastError(2); if hDLL = 0 then RaiseLastOSError; pCode := GetProcAddress(hDLL, PChar(vpeFunction)); if pCode = nil then RaiseLastOSError; Result := TProcMainEntry(pcode)(); [/delphi] in delphi 7 there's a variable filled with data of the main application which used in the...

Delphi 2010 produces much larger binaries than Delphi 2009 [Edit]
When I compile my project with Delphi 2010 the resulting executable is about 30% larger than the one compiled with Delphi 2009. Both binaries are compiled with the same source code and project options. The size of individual DCU files increases by 5-20%. Has anybody experienced similar results? Has anybody an idea what could cause this? It surprises me, as the changes in syntax and VCL have not been that big. Best regards, Joachim Edited by: Joachim Marder on Sep 25, 2009 6:07 AM "Joachim Marder" wrote in message news:166152@forums.codegear.com... > When I compi...

Delphi XE / Delphi 2010
Hello! I noticed that Embarcadero® Delphi® 2010 Version is not on the list of products on Embarcadero page. Or is it still possible to buy it? Will RAD Studio XE compile programs written in Delphi 2010 without problems.? Thanks. Am 13.09.2010 09:04, schrieb Petra Nemec: > Will RAD Studio XE compile programs written in Delphi 2010 without problems.? As always you will probably have to recreate the projects as the import is still a bit -- special. Christian Hello! Does anybody know if it is still possible to get a Delphi2010 trial version (if yes where)? ...

from delphi 6 to delphi 2010
Hi. It is possible, with component RX, dxforumlibrary, InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. Thank by comments. excequiel arostica wrote: >Hi. > It is possible, with component RX, dxforumlibrary, >InfoPower3000Pro, StringAlignGrid. Accepts communication BDE. > >Thank by comments. Rx is dead and sources are taken over by jcl/jvcl. I dont know about the rest of the components and i have no experiences with bde over the last 9 years. excequiel arostica wrote: > Hi. > It is possible, with component RX, dxforumlibrary,...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Price of upgrade from Delphi 2010 Professional to Delphi 2010 Enterprise?
It's weird, but I could not find the answer on so simple question not in Embarcadero Shop, neither by the forum search. For example, the shop info about Enterprise upgrade says: The Upgrade product is available to registered owners of 2006-2009 versions, blah-blah... So, if I'm Delphi 2010 Professional user, I even not eligible for upgrade? I have to buy a new version of Enterprise??? But if I'm Delphi 2006 Professional user, I can upgrade. Please clarify this nonsense for me. Exact question is in the subject. Thanks! Hi Dmitri, > It's weird, but I could not...

Delphi 2010 RTTI doesn't recognize array type
I'm using Delphi 2010 and trying to traverse simple structure by using RTTI. Does anybody know why RTTI cannot recognize array type and return nil instead of actual type? Here is example: type R = record f1: array [0 .. 0] of byte; end; procedure Test; var context: TRttiContext; field: TRttiField; rttiType: TRttiType; begin context := TRttiContext.Create; rttiType := context.GetType(TypeInfo(R)); for field in rttiType.GetFields do if field.FieldType = nil then Writeln('Type is nil.'); context.Free; end; Andrey Tihankov wro...

Delphi 2010 w Delphi 2007
I have D2007 installed on my laptop (XP sp3 running on dual core Athlon). Can I install D2010 on this machine without it affecting D2007? Will D2010 affect D2007 in any way? Thanks, Randall Carpenter > {quote:title=Randall Carpenter wrote:}{quote} > I have D2007 installed on my laptop (XP sp3 running on dual core Athlon). > Can I install D2010 on this machine without it affecting D2007? Will D2010 > affect D2007 in any way? Won't hurt a thing. I have D7, RAD Studio 2007, RAD Studio 2009, and RAD Studio 2010 all on my desktop system and they coexist fine. Jus...

Migrating From Delphi 7 to Delphi 2010
We did not know which forum was the best for this question. We have been wanting to migrate from Delphi 7 to a later version for years but it appears to be a daunting task. We first looked at D2006 and that was a radical new world. We bought D2010 a couple of years ago and not done much with it because there are so many parts to our applications. We have done a few new applications in D2010 and they seem to work okay. D2010 has not been impressive, perhaps because of the strangeness compared to D7. Is is possible for us to do a phased sort of migration where we do a form at a time? ...

Delphi 2010 professional to Delphi XE3
Hello, Sorry for this is not right place to ask this question: I have Delphi 2010 professional version, I like to upgrade to Delphi XE3 Am eligible to upgrade or no not? I like answer from Delphi sales team. I couldn’t find email to ask them. Thanks Mike Thomas <> wrote in news:506459@forums.embarcadero.com: > Hello, > > Sorry for this is not right place to ask this question: > I have Delphi 2010 professional version, I like to upgrade to Delphi > XE3 Am eligible to upgrade or no not? I like answer from Delphi > sales team. I couldn’t find emai...

delphi 2006 code in delphi 2010
hello, is there any option to make delphi 2006 code work in delphi 2010? something like in java IDEs where you can define the code level you like to use? the problem is, that i made a project with 2006 and sent it to my customer. they got 2010 and it compiles fine, but it just doesn't work. it deals with en-/decryption of text, we assumed, that it has something to do with ansi vs. unicode strings... but we cant find the exact position where the error occurs. i am a bit dissapointed, because everywhere i read that the new IDE will always be downwards compatible and so on.. but in ...

Web resources about - Delphi 2010 RTTI Set length dynamic array [Edit] - embarcadero.delphi.non-tech

Dynamics - Wikipedia, the free encyclopedia
Brownian dynamics , the occurrence of Langevin dynamics in the motion of particles in solution (e.g. a grain in water, as was first seen by Brown); ...

Datacenter Dynamics
Datacenterdynamics for data center information, conferences, news, videos, whitepapers and reports globally

Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find ...
Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find a Chiropractor

Master & Dynamic unveils a palladium-coated version of its ME05 earphones
Master & Dynamic might not be a household name, but the New York City based company is continuing to produce some great, high-end audio products. ...

Lenovo and Apple: PCs’ Dynamic Duo, Gobbling Up Share in Downbeat Market
... in units sold, with gains in market share for top vendor Lenovo Group ( 0992HK ), and for Apple ( AAPL ), who turned out to be the Dynamic Duo ...

Seattle Councilmember O'Brien: Power dynamic between Uber, drivers is out of balance
Seattle is the first city in the U.S. to give Uber drivers the right to form a union, but whether that actually happens might be up to the courts. ...

Steel Dynamics, Inc. (STLD) Rating Lowered to Hold at TheStreet
Steel Dynamics, Inc. (NASDAQ:STLD) was downgraded by research analysts at TheStreet to a “hold” rating in a research note issued to investors ...

Dynamic difficulty tuning is coming to Killing Floor 2
Killing Floor has a fairly hardcore following: these folks build wikis to know every single damage value in the game, and pore over enemy animations ...

The story behind Master & Dynamic's mix of sound and design
Master &amp; Dynamic's latest headphones, the wireless over-ear MW60s, may have been announced ahead of CES, but that didn't stop me from getting ...

IBM's Dynamic Pricing Helps Retailers Navigate Online Price Wars
IBM Dynamic Pricing enables retailers to intelligently adjust prices while driving customer loyalty and product demand.

Resources last updated: 2/12/2016 7:55:13 PM