In Notepad you can Open any File and it will display the raw data inside.

I would like to do this in a TMemo but have struggled to find out how to do this.

I managed to find this [code here.](http://www.swissdelphicenter.ch/torry/showcode.php?id=944)

I modified it to a function and changed it slightly for my purposes:

```
function OpenBinaryFile(var Data; Count: Cardinal): string;
var
  Line: string[80];
  i: Cardinal;
  P: PAnsiChar;
  nStr: string[4];
  SL: TStringList;
const
  posStart = 1;
  binStart = 7;
  ascStart = 57;
begin
  P := @Data;
  Line := '';

  SL := TStringList.Create;
  try
    for i := 0 to Count - 1 do
    begin
      if (i mod 16) = 0 then
      begin
        if Length(Line) > 0 then
          SL.Add(Trim(Line));

        FillChar(Line, SizeOf(Line), ' ');
        Line[0] := Chr(72);
      end;

    if P[i] >= ' ' then
      Line[i mod 16 + ascStart] := P[i]
    else
      Line[i mod 16 + ascStart] := '.';
    end;

    SL.Add(Trim(Line));

    Result := SL.Text;
 finally
    SL.Free;
  end;
end;

```

It works, but it only displays in a fixed amount of characters per line, like this:

![enter image description here](https://i.stack.imgur.com/Wb3re.png)

What do I need to change so it fills all the memo in the same way Notepad would?