Oxygene newbie on Classes, Records & TString

In Delphi I have used Array’s of records, e.g.
TYPE TTopic = Record
tfGoodun : Boolean;
fHeading : Single;
fBody : Single;
fTopic : Single;
sCode : String;
sHeading : String;
sNote : String;
sBody : Array of String;
end; //EndRECORD Ttopic

Topics: Array [0…100] of TTopic;

The length of each sBody is set to the size needed for each record before its Strings are set.

The data is set & accessed like:
Topics[3].sCode := ‘tex’;
s := Topics[3].sCode; //where s is a string var.

Elements docs suggest I might be able to do this with Record’s or Classes with Classes having advantages.
Can I?

The doc example of Record is:
type Color = public record(IColor).
// Why is “(IColor)” present? Is it necessary?

The doc example of Class is:
type MyClass = public class(Object, IMyInterface)
//What is “(Object, iMyInterface)” for? Necessary? If so, what do I put for “Object” & “IMyInterface”?

Does Oxygene have the equivalent of Delphi’s TStrings with its methods?

Which part exactly?

This is an example of a record implementing an interface (called IColor). That is an optional on records, and not necessary, no.

Every class is part of the.class hierarchy in Oxygene, and can specify one class as its ancestor. This is optional, and if no ancestor is specified, the new class will descend directly from Object, which is the root of the hierarchy (same as TObject, in Delphi). Classes can also (again optionally) implement on or more interfaces.

We provide this as part of the Delphi RTL compatibility library (see Delphi RTL). Alternatively there is also the more universal generic List<T> class, which can be used with strings as List<String>.

HTH,
marc

If I code:
type TTopic = public clsss()
tfGoodun : Boolean;
fHeading : Single;
fBody : Single;
fTopic : Single;
sCode : String;
sHeading : String;
sNote : String;
sBody : Array of String;
end; //EndCLASS Ttopic

Can I then create my array: Topics: Array [0…100] of TTopic;
and
access it as before: s = Topics[3].sCode; //After setting it of course

If it’s a class you will need to create each instance and fill the array, first, eg:

var Topics: Array [0…100] of TTopic;
for i: Integer := 0 to 99 do
  Topics[I] := new TTopic;

If you make it TTopic record as you had above, it will be in memory in there array itself, and you can access each item directly after creating the array.

Thats because classes are allocated on the heap and the actual class reference is just a pointer to the classes memory (which needs to be allocated, by creating the class — same as in Delphi). You have an array of pointers to classes, and those pointers all start out nil.

Records, by contrast, are allocated locally/on the stack, so your array of records is itself the memory space that each record needs.

Does that make sense?