16

False例として、以下のコード抽出を前提として、オブジェクトフィールドの値が変更されるたびにトリガーされ、オプションで条件(またはTrueこの場合)でブレークするブレークポイントを定義したいと思います。

type
  TForm1 = class(TForm)
    EnableButton: TButton;
    DisableButton: TButton;
    procedure EnableButtonClick(Sender: TObject);
    procedure DisableButtonClick(Sender: TObject);
  private
    FValue: Boolean; // <== Would like to define a breakpoint here whenever FValue changes.
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DisableButtonClick(Sender: TObject);
begin
  FValue := False;
end;

procedure TForm1.EnableButtonClick(Sender: TObject);
begin
  FValue := True;
end;
4

2 に答える 2

28

デバッガーでアプリケーションを実行し、

IDEメニューから「実行」を選択し、一番下の「ブレークポイントの追加」を選択してから、「データブレークポイント...」を選択します。

「Adress:」フィールドへの入力として「Form1.FValue」と入力します。同じダイアログで条件を設定することもできます。

于 2013-01-04T20:49:53.847 に答える
3

Sertacの回答とDavidからのコメントに感謝するいくつかの追加情報。

条件付きの配列アイテムの変更に基づいてブレークポイントを定義できます。

この場合、データブレークポイントは次のように定義されます。

Form1.FBooleans[0] = True

コード抽出:

type
  TBooleanArray = array of Boolean;

  TForm1 = class(TForm)
    EnableButton: TButton;
    DisableButton: TButton;
    procedure EnableButtonClick(Sender: TObject);
    procedure DisableButtonClick(Sender: TObject);
  private
    FBooleans: TBooleanArray; // Breakpoint defined here with the condition
  public
    constructor Create(AOwner: TComponent); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

constructor TForm1.Create(AOwner: TComponent);
var
  AIndex: Integer;
begin
  inherited;
  SetLength(FBooleans, 3);
  for AIndex := 0 to Length(FBooleans) - 1 do
  begin
    FBooleans[AIndex] := (AIndex mod 2) = 1;
  end;
end;

procedure TForm1.DisableButtonClick(Sender: TObject);
begin
  FBooleans[0] := False;
end;

procedure TForm1.EnableButtonClick(Sender: TObject);
begin
  FBooleans[0] := True; // Beakpoint stops here on condition.
end;
于 2013-01-04T23:18:45.377 に答える