Autor Beitrag
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: So 22.05.05 20:16 
Hallo Leute!

Ich möchte in einem record eine Variable angeben, die frei von jeglichen Beschränkungen ist. Also in die man einen String, einen Integer etc. speichern kann.
Ähnlich wie der Buffer-Parameter bei TStream.Write.
Da wurde einfach der Variablentyp in der Definition weggelassen:

ausblenden Delphi-Quelltext
1:
function Write(var Buffer: , Count: Integer): Integer;					


Aber in einer record-Definition geht das ja nicht. Wie kann man sowas lösen?

Alstar

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 22.05.05 21:05 
Hallo,

siehe Delphihilfe >> "TVarRec" oder "Datensatztypen"
hier ein Beispielcode Example code : Record definition with a Case (Variant) tail section

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 22.05.05 21:30 
user profile iconAlstar hat folgendes geschrieben:
Hallo Leute!

Ich möchte in einem record eine Variable angeben, die frei von jeglichen Beschränkungen ist. Also in die man einen String, einen Integer etc. speichern kann.

Könntest du z.B. mit Variant machen und mit VarType prüfen, um welchen Variablentyp es sich handlet.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TMyRecord = record
    ValueA: Variant;
    ValueB: Variant;
  end;

_________________
Ciao, Sprint.