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
- 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>’
- Add a breakpoint to the line Get phoDataSource to hoDataSource
- Click ‘run’ from the top toolbar
- 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’
- In the Breakpoints window, that breakpoint’s icon is now white and is unchecked showing that it is disabled
- Click ‘Run’ from the top toolbar to run the program
- Click ‘Yes’ from the Yes/No prompt window that appears
- New variables can now be seen in the Locals window
- Right click in the left column next to
- If (InvtData[iElement].sValue[iWeightColumn] > 0) Begin
- …and select ‘Run to Cursor’
- This will cause the Debugger to skip over several lines of code at once
- The Locals window now shows that the array is full of data
- 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’
- The invtdata array is dragged into the Watches window
- Expanding the array exposes the individual elements
- Each element is of datatype ‘tDataSourceRow,’ which is a predefined structure datatype in the DataFlex Framework
- Each struct can also be expanded to view its data
- 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
- ‘.sValue’ can also be added to just view the sValue member of the current struct
- To drill down further, a member number can be added in square brackets
- By adding a breakpoint to the line
- If (InvtData [iElement].sValue[iWeightColumn] > 0) Begin
- …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>’
- The iElement value will increase every time the ‘Continue’ icon is clicked to loop through the elements in the array
- Anything that can be evaluated as an expression, can be highlighted in the Code Editor, and dragged into the Watches window