Compartir a través de


Debugger3.ExecuteStatement(String, Int32, Boolean) Method

Definition

Executes the specified statement. If the TreatAsExpression flag is true, then the string is interpreted as an expression, and output is sent to the Command Window.

void ExecuteStatement(std::wstring const & Statement, int Timeout = -1, bool TreatAsExpression = false);
[System.Runtime.InteropServices.DispId(11)]
public void ExecuteStatement (string Statement, int Timeout = -1, bool TreatAsExpression = false);
[<System.Runtime.InteropServices.DispId(11)>]
abstract member ExecuteStatement : string * int * bool -> unit
Public Sub ExecuteStatement (Statement As String, Optional Timeout As Integer = -1, Optional TreatAsExpression As Boolean = false)

Parameters

Statement
String

The statement to execute.

Timeout
Int32

The timeout period, in milliseconds.

TreatAsExpression
Boolean

true if the string is to be interpreted as an expression; otherwise false.

Implements

Attributes

Examples

The following example shows how to use the ExecuteStatement method.

public static void ExecuteStatement(EnvDTE80.DTE2 dte)  
{  
    // Setup debug Output window.  
    Window w =   
    (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);  
    w.Visible = true;  
    OutputWindow ow = (OutputWindow)w.Object;  
    OutputWindowPane owp = ow.OutputWindowPanes.Add("ExecuteStatement   
    Method Test");  
    owp.Activate();  

    EnvDTE90.Debugger3 debugger = (EnvDTE90.Debugger3)dte.Debugger;  
    debugger.ExecuteStatement("tempC = 100.0", 100, false);  
    owp.OutputString("The new value of tempC variable is: " +   
                     debugger.GetExpression("tempC", false, 1).Value);  
}  
' The following executes a statement, effectively  
' setting a to the value of 2.  
Sub SetVariable()  
    DTE2.Debugger.ExecuteStatement("a = 2", -1, False)  
End Sub  

' The following tests the value of a against  
' the value of 2.  False is displayed in the command window.  

Sub TestVariable()  
    DTE2.Debugger.ExecuteStatement("a = 2", -1, True)  
End Sub  

Remarks

ExecuteStatement executes the specified statement. A statement differs from an expression in that a statement can consist of one or more expressions. Therefore, typically no value can be associated or returned by statement execution.

Some languages, such as Visual Basic, support a language syntax that relies on the context in which a statement appears to indicate how the statement is evaluated. For example, if your Visual Basic code has statement, a = 1, it is interpreted as an expression if the code appears inside an If…Then statement. It is interpreted as a statement if it appears alone on a line. The expression tests a against the value of 1, the statement will set a equal to 2. See the following example.

Output from this method is sent to the Command Window.

Applies to