PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 
 
Debugging Datastore Contents
I've been using the Visual Studio .NET IDE for a while and one of the features I like is the expressions pane in the debugger, in there you can use the ? symbol and then query the value of a variable or type any expression, which can be really useful when dealing with complex objects like XMLDocuments where you want to see what the XML looks like at a given point.

Recently I was debugging some PowerBuilder code and I'd been tracing through for a while until the problem appeared and  I knew the solution to the issue would be the data in a particular data store but I wanted to see what the data looked like at the point in time.

My initial thought was wouldn't it be cool if i was using Visual Studio, I could use the ? feature and like I do with the XMLDocument object, I could just export the contents of the data store. I quit debugging and added a bunch of code to the function to export the data store depending on a bunch of criteria and started rerunning my test.

During the test I added a bunch of watches to variables and then it occurred to me that I maybe able to use the watch to execute expressions like in Visual Studio. A quick test and it worked a treat, of course you don't get the popup syntax stuff like Visual Studio but the results are the same.

In my example I wanted to get the contents of a data store so I just added a watch with an expression to dump out the data store to an Excel file as follows:

  • Right click in the watch view and select the Insert menu item
  • In the Edit Expression Dialog I added this code:

    inc_comp.ids_res().saveas( 'c:\resdata.xls', Excel5!, true )

This creates the file on disk and as you can see you can use the full Powerscript commands, here I am calling a method to get eh private data store and then calling the SaveAs function. 

One thing to watch for is that the watch expression gets executed every time you step in the debugger so your file can get over written and if its an expensive command then it can slow down your machine while it is executed every step. I would recommend deleting the watch as soon as you have the results you needed.

 

Top of Page

Legal Notice

Ken Howe 2011