Re: Dynamic arrays of record/object
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 01:05:32 -0500
sakkieLFS@xxxxxxxxx wrote:
On Mar 13, 1:31 am, Rob Kennedy <m...@xxxxxxxxxxx> wrote:sakkie...@xxxxxxxxx wrote:procedure TForm1.Button1Click(Sender: TObject);
var Data: TXMLSectionData;
begin
Data.Create;
That line will surely fail. Doesn't the compiler warn you about using an
uninitialized variable?
Data.AddSection('Header1','test data');
end;
function TXMLSectionData.GetCount: integer;
begin
Result := FCount;
end;
Hi, if I remove the constructor, desctructor and unnecesary properties
it works fine,
No it doesn't. None of those were problems. They were just things that made your code more complicated.
The problem is where you call Data.Create. It's a common mistake, but the compiler should warn you about it because you're calling a method on a variable that hasn't been initialized.
but if I now change TSectionData to a class instead of
a record (which I ultimately need it to be) again it doesn't work????
You need to be more specific than "doesn't work." What fails? Why? What debugging effort have you made?
Can this be done?
TSectionData = class(TObject)
private
DataHeader: string;
Data: string;
public
end;
That's a useless class. It's entirely private data, which isn't accessible outside the class.
--
Rob
.
- Follow-Ups:
- Re: Dynamic arrays of record/object
- From: sakkieLFS
- Re: Dynamic arrays of record/object
- References:
- Dynamic arrays of record/object
- From: sakkieLFS
- Re: Dynamic arrays of record/object
- From: Rob Kennedy
- Re: Dynamic arrays of record/object
- From: sakkieLFS
- Dynamic arrays of record/object
- Prev by Date: Re: Dynamic arrays of record/object
- Next by Date: Re: Dynamic arrays of record/object
- Previous by thread: Re: Dynamic arrays of record/object
- Next by thread: Re: Dynamic arrays of record/object
- Index(es):