Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

SimpleTypesView

View and edit the value of simple types in Delphi

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

Delphi 'Simple' Types Viewer

View and edit the value of simple types in Delphi

How well do you know the simple types in Delphi? This makes use of a variant record to store multiple simple types in the same memory. The UI renders that same internal value as each distinct type, allowing you to see how a value in one type looks when converted into a different type. The sliders allow you to edit the values of the individual bytes, while the checkboxes along the bottom allow you edit the individual bits.

Simple Types View User Interface

The Bytes and GUID rows are not editable. A variant record can't contain a normal string, so it is an array of WideChar instead.

delphi
type
  TypeUnion = record
    const
      BytesIndex = 0;
      Real48Index = 7;
      WideCharIndex = 11;
      AnsiCharIndex = 12;
      ShortStringIndex = 13;
      GuidIndex = 14;
      DateTimeIndex = 15;
      RectIndex = 16;
      PointFIndex = 17;
      ColorsIndex = 18;
      AlphaColorsIndex = 19;
    case byte of
      // These MUST be in INDEX order
      BytesIndex: (AsBytes: array [0..15] of Byte);

      // --- INTEGERS ---
      1: (AsCardinal: Cardinal);        // 4 bytes (Unsigned)
      2: (AsInteger: Integer);          // 4 bytes (Signed)
      3: (AsInt64: Int64);              // 8 bytes (Signed)
      4: (AsUInt64: UInt64);            // 8 bytes (Unsigned)

      // --- FLOATING POINT & TIME ---
      5: (AsSingle: Single);            // 4 bytes
      6: (AsDouble: Double);            // 8 bytes
      Real48Index: (AsReal48: Real48);  // 6 bytes (Legacy)
      8: (AsExtended: Extended);        // 10 bytes (Win32) or 8 bytes (Win64)
      9: (AsCurrency: Currency);        // 8 bytes (Fixed point)
      10: (AsComp: Comp);               // 8 bytes (Integer viewed as float)

      WideCharIndex: (AsWideChar: array [0..7] of WideChar);  // 16 bytes
      AnsiCharIndex: (AsAnsiChar: array[0..15] of AnsiChar);  // 16 bytes
      ShortStringIndex: (AsShortString: string[15]);          // 16 bytes
      GuidIndex: (AsGuid: TGUID);                             // 16 bytes

      DateTimeIndex: (AsDateTime: TDateTime);                 // 8 bytes (Date/Time)
      RectIndex: (AsRect: TRect);                             // 16 bytes (Left, Top, Right, Bottom)
      PointFIndex: (AsPointF: TPointF);                       // 8 bytes (X, Y) 2 Singles

      ColorsIndex: (AsColors: array [0..3] of TColor);
      AlphaColorsIndex: (AsAlphaColors: array [0..3] of TAlphaColor);

I feel like calling this "simple" is no longer accurate.