You can use the case statement to map different types of variables in the same memory space.The types used must be equal size, ie. Cardinal = 4 bytes in this case.
Code:
MyColor.R := $FF;
MyColor.G := $00;
MyColor.B := $FF;
MyColor.A := $00;
// Is equal to
MyColor.C := $00FF00FF;
Another example
Code:
TVector = record
case Integer of
0: (x, y, z: Single);
1: (v: array [0..2] of Single);
end;
MyVector.x := 5.75;
MyVector.y := 1.75;
MyVector.z := 0.00;
// Is equal to
MyVector.v[0] := 5.75;
MyVector.v[1] := 1.75;
MyVector.v[2] := 0.00;
Bookmarks