Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Misc > Dynamic arrays ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 13 Topic 6010 of 6114
Post > Topic >>

Dynamic arrays of record/object

by sakkieLFS@[EMAIL PROTECTED] Mar 12, 2008 at 11:46 AM

Hi Al,

I ready to pull out my hair on the creation of dynamic arrays of a
record or object. For some reason I'm having problems setting the
lenght of the array and assigning values to the elements of the array
(which is a record). I have included source code. Please help!


type

  TSectionData = record
    DataHeader: string;
    Data: string;
  end;


  TXMLSectionData = class(TObject)

  private
    FCount: Integer;
    FSectionData: array of TSectionData;
    function GetCount: integer;
  public

    constructor Create;
    destructor Destroy; override;

    property Count: integer read GetCount write FCount;

    procedure AddSection(DataHeader: string; Data: string);

  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TXMLSectionData }

procedure TXMLSectionData.AddSection(DataHeader, Data: string);
begin
  SetLength(FSectionData,FCount+1);
  FSectionData[FCount].DataHeader:= DataHeader;
  FSectionData[FCount].Data:= Data;
  Inc(FCount);
end;

constructor TXMLSectionData.Create;
begin
  inherited;
  FCount:= 0;
  SetLength(FSectionData,FCount);
end;

destructor TXMLSectionData.Destroy;
begin

  inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
var Data: TXMLSectionData;
begin
  Data.Create;
  Data.AddSection('Header1','test data');

end;

function TXMLSectionData.GetCount: integer;
begin
  Result := FCount;
end;

end.
 




 13 Posts in Topic:
Dynamic arrays of record/object
sakkieLFS@[EMAIL PROTECTE  2008-03-12 11:46:46 
Re: Dynamic arrays of record/object
Rob Kennedy <me3@[EMAI  2008-03-12 18:31:17 
Re: Dynamic arrays of record/object
"Maarten Wiltink&quo  2008-03-13 10:28:13 
Re: Dynamic arrays of record/object
Hans-Peter Diettrich <  2008-03-12 23:08:41 
Re: Dynamic arrays of record/object
Rob Kennedy <me3@[EMAI  2008-03-13 01:07:21 
Re: Dynamic arrays of record/object
sakkieLFS@[EMAIL PROTECTE  2008-03-12 22:57:12 
Re: Dynamic arrays of record/object
Rob Kennedy <me3@[EMAI  2008-03-13 01:05:32 
Re: Dynamic arrays of record/object
sakkieLFS@[EMAIL PROTECTE  2008-03-12 23:09:38 
Re: Dynamic arrays of record/object
Hans-Peter Diettrich <  2008-03-13 17:15:23 
Re: Dynamic arrays of record/object
sakkieLFS@[EMAIL PROTECTE  2008-03-12 23:21:59 
Re: Dynamic arrays of record/object
sakkieLFS@[EMAIL PROTECTE  2008-03-12 23:56:26 
Re: Dynamic arrays of record/object
Jamie <jamie_ka1lpa_no  2008-03-13 19:04:01 
Re: Dynamic arrays of record/object
"alanglloyd@[EMAIL P  2008-03-13 02:32:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:50:47 CDT 2008.