Yes, however...

Use a dynamic array instead if you want to store records. You need to know
how to use them but when you do, they're a lot more practical to use than
stringlists or TLists.

Declaration:
  type TARecords = array of TARecord;
  var ARecords: TARecords;
  var Index: Integer; // For some of the following examples...

Initializing:
  SetLength(ARecords, 0);

Freeing all records.
  SetLength(ARecords, 0);

Adding record to the end:
  Index := Length(ARecords);
  SetLength(ARecords, Succ(Index));
  ARecords[Index].Field1 := ...;
  ARecords[Index].Field2 := ...;
  ...

Deleting record at position Index:
  while (Index < High(ARecords)) do begin
    ARecords[Index] := ARecords[Succ(Index)];
    Inc(Index);
  end;
  SetLength(ARecords, Index);

Things become a bit more complicated if you need these records to be sorted,
though.


On 7/29/07, reynaldi81 <[EMAIL PROTECTED]> wrote:
>
> hi i'm trying to put a record into TStringList.
>
>
> type
> TARecord = record
>    s: String[5];
> end;
>
> var
> rec: TARecord;
> begin
>   GetMem(rec, SizeOf(TARecord));
>   StringList.AddObject('', rec);
> end;
>
>
> my question is, do i have to freemem each record in tstringlist?
>
> thanks in advance
>


[Non-text portions of this message have been removed]

Reply via email to