Microsoft KB Archive/284981

= How To Set Conditional Breakpoints in the Visual InterDev Debugger =

Article ID: 284981

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q284981



SUMMARY
In the Visual InterDev debugger, you can set conditional breakpoints that cause the debugger to break only when certain conditions are true. This feature is useful when you are debugging code that has many possible values and you only want to test for certain values.



MORE INFORMATION
The conditional breakpoint feature of Visual InterDev is implemented differently from the other Microsoft Visual Studio development environments. To set conditional breakpoints in Microsoft Visual Basic, for example, you create a &quot;watch expression&quot; and then set various properties of the expression, such as the context in which it breaks and the value that causes it to break. In Visual InterDev, you cannot set conditions directly on watches, but you can use a different approach for conditional breakpoints.

How to Set Conditional Breakpoints in Visual InterDev
The following Active Server Pages (ASP) sample code loops through an ActiveX Data Objects (ADO) Recordset, which is created from the Pubs sample database in SQL Server, and writes the field values in a table: To trigger a breakpoint when rs.fields(&quot;au_fname&quot;) evaluates to &quot;Meander&quot;, follow these steps:
 * 1) Make sure that you view the code in Source View in Visual InterDev.
 * 2) Right-click the line of code where you want to set the breakpoint.
 * 3) On the context menu, click Insert breakpoint.
 * 4) On the Debug menu, click Breakpoints.
 * 5) In the Breakpoints dialog box, the breakpoints are distinguished by file name and line number. Select your breakpoint, and then click Properties.
 * 6) In the Script Breakpoint Properties dialog box, in the Condition text box, type rs.fields(&quot;au_fname&quot;) = &quot;Meander&quot;, and then click is true.
 * 7) Click OK twice to close each dialog box.

After you create the condition, click Start on your toolbar or on the debug menu to launch the debugger. The debugger hits your breakpoint and stops when the condition is true. To verify that the debugger stops when the condition is true, check the value of the field in the Locals window, or type the following code in the Immediate window: ?rs.fields(&quot;au_fname&quot;)

It is important to remember that you can only put simple, non-evaluative code in the Conditions text box of the Breakpoints dialog box. You cannot enter functions or subroutines, even built-in ones such as the Date function. For example, if you enter the following code left(rs.Fields(&quot;phone&quot;),3) = &quot;801&quot; in the Conditions text box, you receive an error message, even though this code works when it is executed in the ASP page. If you want to test for such a condition (for example, if you wanted to stop the debugger when the &quot;phone&quot; field has an area code of &quot;801&quot;), follow these steps:  Declare a variable.  In a temporary line of code, assign the result of the function to the variable. For example: SomeVar = left(rs.Fields(&quot;phone&quot;),3)  In the Conditions text box of the Breakpoints dialog box, type SomeVar = '801' .

Additional query words: debug debugging breakpoint condition conditional watch watches

Keywords: kbhowto kbbug kbide kbdebug kbdevstudio KB284981

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.