Frage : Wie komme ich an den Typ (ShortString) und dessen Länge (in dem Fall 125) ran ?
Nicht so, wie du es geschrieben hast. Aber so:
Delphi-Quellcode:
type
TString125 = String[125];
TSampleRec = packed record
Id: Integer;
FirstName: String;
LastName: String;
MiddleName: TString125;
Sex: Char;
IsActive: Boolean;
end;
var rttiType: TRttiType := TRttiContext.Create.GetType(TypeInfo(TSampleRec));
if rttiType <> Nil then
begin
var recFieldType: TRttiType;
for var field: TRttiField in rttiType.GetFields do
begin
recFieldType := field.FieldType;
if (recFieldType is TRttiStringType)
and (TRttiStringType(recFieldType).StringKind = skShortString) then
begin
ShowMessage((TRttiStringType(recFieldType).TypeSize - 1).ToString);
end;
end;
end;
Bis bald...
Thomas