Article View: borland.public.delphi.language.objectpascal
Article #164how to pass a record to a component?
From: Poetje78
Date: Thu, 08 Mar 2007 16:31
Date: Thu, 08 Mar 2007 16:31
47 lines
2220 bytes
2220 bytes
hi, i have a question,
if i try to run the following code i get the error "Left side cannot
be assigned to".
i understand that this has something to do with the usage of TypeA.
My question is, how can you pass records to components? because,
apparently, the following approach does not work.
thank you all in advance,
Type TypeA=record
some_int:integer;
some_real:real;
end;
Type TypeB = class(TComponent)
private
PrivateA: array of TypeA;
function GetA(index:integer):TypeA;
procedure SetA(index:integer;value:TypeA);
public
procedure SetLengthA(i:integer);
property A[i:integer]:TypeA read GetA write SetA;
end;
procedure TypeB.SetLengthA(i:integer);
begin
setlength(PrivateA,i);
end;
function TypeB.GetA(index:integer):TypeA;
begin
result:=PrivateA[index];
end;
procedure TypeB.SetA(index:integer;value:TypeA);
begin
PrivateA[index]:=value;
end;
procedure TForm1.Button1Click(Sender: TObject);
var B: TypeB;
begin
B:=TypeB.create(nil);
B.SetLengthA(3);
B.A[1].some_int:=5; // <----------- this causes the error !
end;
Technical Details
Message-ID:
<1173371463.152428.251530@s48g2000cws.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!s48g2000cws.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 109d30,73f598ccbd7e07a3,start X-Google-Attributes: gid109d30,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!s48g2000cws.googlegroups.com!not-for-mail From: Poetje78@gmail.com Newsgroups: borland.public.delphi.language.objectpascal Subject: how to pass a record to a component? Date: 8 Mar 2007 08:31:03 -0800 Organization: http://groups.google.com Lines: 48 Message-ID: <1173371463.152428.251530@s48g2000cws.googlegroups.com> NNTP-Posting-Host: 145.18.177.98 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1173371480 13078 127.0.0.1 (8 Mar 2007 16:31:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Mar 2007 16:31:20 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: s48g2000cws.googlegroups.com; posting-host=145.18.177.98; posting-account=O6DAGwwAAADFNYCC6RYP43iEsKWI7BCa