To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Conditional Breakpoints
Cancel

Debugging DataFlex Apps

Lesson 5: Watches Window

The Watches Window evaluates watches based on one of the following…

  • Where the Debugger is currently paused
  • A method selected in the Call Stack window
  • A method selected in the Message Trace Window

In the Watches Window, a developer can customize what to watch…

  • Variables, properties and expressions can be added
  • Items can be dragged and dropped from most other windows
  • Items can be manually entered by typing into an empty row
  • Watches can only be added while the Debugger is paused

Expressions in the Watches Window are evaluated by the program and can affect the state of the running program. 


Watches Window Demonstration

  1. In the DataFlex Studio, with OrdersGenerator.vw open, navigate to a sample function called ‘ToBeUsedInvt,’ right click on it, and select ‘Go To Definition <ToBeUsedInvt>’
  2. Add a breakpoint to the line Get phoDataSource to hoDataSource
  3. Click ‘run’ from the top toolbar
  4. The program will pause at a previously defined breakpoint that is not currently needed
    • To disable the unneeded breakpoint, right click in the margin next to the breakpoint and select ‘Breakpoint Enable/Disable’
  5. In the Breakpoints window, that breakpoint’s icon is now white and is unchecked showing that it is disabled
  6. Click ‘Run’ from the top toolbar to run the program
  7. Click ‘Yes’ from the Yes/No prompt window that appears
  8. New variables can now be seen in the Locals window
  9. Right click in the left column next to 
  10. If (InvtData[iElement].sValue[iWeightColumn] > 0) Begin
  11. …and select ‘Run to Cursor’
  12. This will cause the Debugger to skip over several lines of code at once
  13. The Locals window now shows that the array is full of data
  14. Several of the watches display errors because they are not defined in the current method
    • Since the current watches are not pertinent, right click and select ‘Remove All’
  15. The invtdata array is dragged into the Watches window
  16. Expanding the array exposes the individual elements
  17. Each element is of datatype ‘tDataSourceRow,’ which is a predefined structure datatype in the DataFlex Framework
  18. Each struct can also be expanded to view its data
  19. To switch the watch from the entire array to just the array element the current loop iteration is on, add the loop counter in square brackets to the end of the array name and press enter
  20. ‘.sValue’ can also be added to just view the sValue member of the current struct
  21. To drill down further, a member number can be added in square brackets
  22. By adding a breakpoint to the line 
  23. If (InvtData [iElement].sValue[iWeightColumn] > 0) Begin
  24. …and selecting run the program pauses at this line at every loop iteration 
    • To see which iteration the loop is in, add a loop counter by right clicking on the line and selecting ‘Add to Watch <iElement>’
  25. The iElement value will increase every time the ‘Continue’ icon is clicked to loop through the elements in the array
  26. Anything that can be evaluated as an expression, can be highlighted in the Code Editor, and dragged into the Watches window