Breakpoints
When the program is running and a breakpoint is encountered, the program enters break mode. When the program is in break mode, all debug windows are updated with current information and enabled. Setting and executing breakpoints is perhaps the single most important step in debugging a program.
The Studio allows you to easily set multiple breakpoints, disable and enable all or any breakpoint, and view the source where each breakpoint is set.
Setting Breakpoints
You set breakpoints directly in the Code Editor by finding the source location to place the breakpoint and clicking in the left margin of the editor. You can also right-click and select Breakpoint Set/Remove, or press F9. The Breakpoints window also lets you manage existing breakpoints and remove all breakpoints at the same time, for example.
Enabling and Disabling Breakpoints
Breakpoints can be enabled and disabled. The difference between removing and disabling a breakpoint is that a disabled breakpoint can be easily re-enabled. Disabled breakpoints are also still listed in the Breakpoints window.
You can enable/disable individual breakpoints directly in the Code Editor by finding the source line with the breakpoint, right-clicking, and selecting Breakpoint Enable/Disable, or pressing Ctrl+F9.
You can also enable/disable all breakpoints at the same time using the Breakpoints window.
Conditional Breakpoints
A Condition Expression can be applied to any breakpoint. Each time the breakpoint is encountered during execution of your program, the expression is evaluated: If the expression evaluates to True, then the program enters break mode; if False, then the program continues without breaking.
You can apply a breakpoint condition in the Code Editor by finding the source line with the breakpoint, right-clicking, and selecting Breakpoint Condition. You can also apply a breakpoint condition using the Breakpoints Window.
Of Special Note
Setting Breakpoints on If and Else Commands
Placing a breakpoint on an If statement works as expected. The break will occur before the if statement is executed.
Placing a breakpoint on an Else command will probably not work as expected. The method the DataFlex compiler uses for creating else statements is confusing when used with a debugger. Internally, the else command will not get executed if the else condition is true, but it will get executed if the condition is false (at which point it skips the else block). While this works perfectly, it is somewhat debugger unfriendly.
If you wish to break on an Else statement, you will need to break on the first line of code within the else block. For example:
If SomeCondition Begin
...
End
Else Begin
// Do not place Break here!
Send DoSomething
// Place Break Here
...
End
If your Else command executes a single command and does not use a Begin/End block, you will have to place the breakpoint on the If statement and then single step into the else code.
Setting Breakpoints on Procedures and Functions
Very often you will wish to place a breakpoint at the start of a function or a procedure. To do this, you must place your breakpoint on the first executable line within the function and procedure, and not on the source line that contains the function or procedure statement. For example:
Procedure DoSomething Integer iVal
// Do not place Break here!
Integer iCount
// Place Break Here
End
DataFlex function and procedure statements are executed when the program is being initialized and not when the actual procedure or function is called. When the function or procedure is called, execution is passed to the first line in the method.