Does anyone has a trick for quickly put in clipboard the content of a string variable while debugging ?  Variable  inspection is  great, but string must be processed as it's displayed quoted and with #$D#$A instead of linebreaks .... Ty

Comments

  1. Jamie Oliver - - You can try something like this:

    type
      TForm10 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        FClipStr: String;
      public
        { Public declarations }
      public
        function CopyToClipboardForDebugging: Boolean;
      end;

    var
      Form10: TForm10;

    implementation

    {$R *.dfm}

    function TForm10.CopyToClipboardForDebugging: Boolean;
    begin
      Result := TRUE;

      Clipboard.AsText := FClipStr;
    end;

    procedure TForm10.Button1Click(Sender: TObject);
    begin
      FClipStr := 'Test';

      FClipStr := 'Another Test';
    end;

    -----

    CopyToClipboardForDebugging needs to be declared public otherwise it will be eliminated by the linker.

    Add a watch on CopyToClipboardForDebugging (make sure you select  "Allow side effects and function calls") FClipStr will be copied to the clipboard while stepping through your code.

    ReplyDelete
  2. Oh nice idea, I wouldn't have think to use clipboard directly in code ! Thank you Paul Thornton !

    ReplyDelete
  3. Is it possible to write a debugger visualizer for strings?

    ReplyDelete
  4. +Lars Fosdal Well, it looks like the OP is asking for this to make looking at the contents of string variables easier to read while debugging. A replacement debug visualizer could solve the same problem without needing to mess about with the clipboard or add extra unnecessary code to the project.

    ReplyDelete
  5. My typical usage for that is SQL queries ... I quickly made a macro in Notepad++ to convert 'Delphi' string to normal string, but  it would be great to have a mean to have it directly ....

    ReplyDelete

Post a Comment