Debugging DataFlex Apps
Lesson 4: Locals, Globals, Call Stack windows & useful actions
- The Locals window lists all local variables in the following context…
- Where the Debugger is currently paused
- The method selected in the Call Stack window
- The method selected in the Message Trace window
- Note: Values of local variables can also be altered in the Locals window
![](/ContentData/2203-DFdebuggerIntro_L4_1_slide1.png)
- The Globals Window lists…
- Predefined global variables in packages that are currently compiled the program
- Global variable in the program code
- Note: Values of global variables can also be altered in the Globals window
![](/ContentData/2204-DFdebuggerIntro_L4_2_slide2.png)
- The Call Stack Window…
- Lists all methods called in the program to reach the current execution point
- With the first method called at the lowest stack level
- With the last method called at the highest/top stack level
- Allows the stepping through of all called methods while examining variables, locals, and so on in that context
- Click on the top stack level to return to where the Debugger is currently paused
![](/ContentData/2205-DFdebuggerIntro_L4_3_slide3.png)
![](/ContentData/2206-DFdebuggerIntro_L4_4_slide4.png)
Useful Actions While Debugging
- Step Over: executes the current line of code and pauses on the following line
- Step Into: steps into the method being called on the current line of code
- Step Out: steps out of the current method and returns to the method that called it
- Set Next Instruction: moves the instruction marker to the selected line of code
![](/ContentData/2207-DFdebuggerIntro_L4_5_slide5.png)
- Typically, the instruction marker is only moved within the method currently being worked on because moving outside of the current scope may cause unexpected behavior
![](/ContentData/2208-DFdebuggerIntro_L4_6_slide6.png)
- Run to Cursor: executes the program to the selected line
- This allows the skipping of several lines of code with having ‘step over’ each one individually, and does stop at enabled breakpoints
- Pause: manually pauses the running program at the next possible opportunity without requiring a breakpoint
- Continue: continues the running program until a breakpoint is encountered or is manually paused
- Restart: stops and restarts the program in debug mode
![](/ContentData/2209-DFdebuggerIntro_L4_7_slide7.png)
Demonstration
The current view shows the source code for the ‘Generate’ button that was navigated to in previous lessons, and it is currently paused where a breakpoint has been added – If (bSpeckOk) Begin
- Selecting the ‘Step Over’ icon from the top toolbar executes the current line of code, and then pauses again on the following line
![](/ContentData/2210-DFdebuggerIntro_L4_8_stepOver.png)
![](/ContentData/2211-DFdebuggerIntro_L4_9_SteppedOver.png)
- Cursor over any item in the Code Editor for the Debugger to evaluate it
- If it’s a variable the current value will be shown
- Example: bRemoveExistingData
- When initially hovered over, it shows as blank because it has not been initialized
![](/ContentData/2212-DFdebuggerIntro_L4_10_blank.png)
- Select the ‘Step Over’ icon again to execute the current line containing bRemoveExistingData
- Now when bRemoveExistingData is hovered over its value shows as ‘false’
![](/ContentData/2213-DFdebuggerIntro_L4_11_false.png)
- The value is also displayed in the Locals window, and it is red because the value has changed since the last time the Debugger was paused
![](/ContentData/2214-DFdebuggerIntro_L4_12_LocalsFalse.png)
- The value of variables can be edited within the Locals window – bRemoveExistingData can be changed to ‘true’
![](/ContentData/2215-DFdebuggerIntro_L4_12_LocalsTrue.png)
- Selecting the ‘Step Over’ icon again causes it to step into the ‘If’ (true) block of code
![](/ContentData/2216-DFdebuggerIntro_L4_13_IfTrue.png)
- If the value had remained false it would have stepped into the ‘Else’ (false) block of code
- To re-execute the if statement using the variable’s original value of ‘false’ …
- Right-click in the left margin next to the line of code that is to be re-executed, and select ‘Set Next Instruction’ to change the current line in the Debugger to that line
![](/ContentData/2217-DFdebuggerIntro_L4_14_SetNext.png)
- In the Locals window, change the value of bRemoveExistingData back to ‘false’
- Now selecting the ‘Step Over’ icon again causes it to step into the ‘Else’ (false) block of code
![](/ContentData/2218-DFdebuggerIntro_L4_15_IfFalse.png)
- The next line of code in the program displays a ‘Yes/No’ message box to the user and asks for user input
- If the ‘Step Over’ icon is selected again the execution does not return to the Debugger because the program has displayed the message box, and is awaiting user input
- Selecting ‘Yes’ from the running program results in the Debugger being paused on the next line of code
![](/ContentData/2219-DFdebuggerIntro_L4_16_chooseYes.png)
- Hovering over the return value variable, iAnswer, and the constant, MBR_Yes, to see that both values are ‘6’
![](/ContentData/2220-DFdebuggerIntro_L4_17_value6.png)
- Stepping over that line to execute the If statement to the next, which calls the DoProcess method of the oOrdersGeneratorBPO object
![](/ContentData/2221-DFdebuggerIntro_L4_18_doProcess1.png)
- Clicking the Step Into icon here moves the execution into the DoProcess method
![](/ContentData/2222-DFdebuggerIntro_L4_19_stepInto.png)
![](/ContentData/2223-DFdebuggerIntro_L4_20_doProcess2.png)
- Note that the contents of the Locals window have changed to the new context, which is the DoProcess method
![](/ContentData/2224-DFdebuggerIntro_L4_21_localsChng.png)
- The ‘Call Stack’ panel on the right contains the list of nested methods the program has called
![](/ContentData/2225-DFdebuggerIntro_L4_22_callStack.png)
- Clicking on any method in the list will cause the context of Debugger and all associated windows will change to that method
- If other methods are viewed, the program will remain paused in DoProcess
- Clicking on the top item in the ‘Call Stack’ will return the view back to where the program is currently paused