Results 1 to 10 of 13

Thread: question about records

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    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;
    Last edited by vgo; 02-10-2010 at 10:29 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •