PowerBuilder – Datawindow ‘SuperSpy’ tool

Posted on Friday, October 7th, 2011 at 8:20 pm in

Not too long ago I came across some information on a free Powerbuilder tool call ‘DWSpy’ written by Michael Zuskin (site is gone now apparently). In certain respects it is similar to my Window Object information service although geared towards datawindows. I decided to expand on the tool a bit by changing it into a visual user object which can be called from any window in an application.

The tool itself is designed to be used while running your application within the Powerbuilder IDE. If you retrofit it into you ancestor objects it can be implemented even in mature apps without much trouble. I’ve provided a sample application which contains three PBLs. The DW_SPY.PBL contains the datawindow objects, windows, and menu for the application. The DW_SPY_STUFF.PBL contains the components needed to implement the functionality (this is the pbl you would need to drop into your existing application). The DW_SPY_ANCESTOR.PBL contains the datawindow and window ancestor objects used by the windows and datawindows in the application (contained in DW_SPY.PBL). I’ve separated these and kept them very simple so you can easily see what modifications to do in your app to implement this too.

Since the tool shows a great deal of information with regards to the datawindow I’ve included a copy of SQLite2009 Pro Enterprise Manager which, when installed, provides the driver needed for the sample application to display ‘SQL’ data. The database is contained in the file DWSPY.DB3. If you don’t want to install SQLite the app will still run but you are limited to the external datawindows provided.

To display the spy window when running the application, you first must click on a datawindow and then Shift + Ctl + Rt Mouse Button while on the datawindow or the parent window background. Depending upon the datawindow column you click on the spy display appears like this:

Depending upon the field in the datawindow initially selected prior to bringing up the spy window, the buttons along the left of the spy will change. The buttons themselves generate text which is inserted into the Window Information datawindow on the right. By default the information is appended to whatever is already in the datawindow. Unselecting the ‘Append Data’ option will cause and previous information to be overwritten.

Here is an example of the output from the ‘On-Window Classes Hierarchy’ button.

The options ‘Save DW as Excel File’ and ‘Save DDDW as Excel File’ will save the datawindow or the DDDW of the field selected (if appropriate) as an Excel spreadsheet and then open the spreadsheet. The spreadsheet files themselves will be saved in the location indicated in the ‘Export File Folder’ field.

The ‘Show DW Syntax’ button will insert the entire DW syntax into the Window Information datawindow. It can then be edited if desired and then re-imported via the ‘Create DW’ option. The can be useful if you need to create a series of datawindow objects with similar fields, properties, or whatever. You can only import a DW if the output from the ‘Show DW Syntax’ option is present in the Window Information datawindow. The new datawindow object will be created in the same PBL as the datawindow the syntax was created from with a timestamp appended to it so the name is unique.

This tool was written in PB11.5 which added tooltip functionality to datawindow columns. If you wish to ‘retrofit’ it to run in a previous version you will need to manually edit the datawindow export files provided, change the version number, remove the column references to tooltips (enabled, icon, text, etc.), and remove the html/xml stuff at the end prior to importing it. If someone wants to do this and send me the previous version exports, I will update the download file for others to use.

A zip archive containing PBLs, exports, and database can be downloaded from here.

To use the database file you need to download and install the SQLite 2009 Pro application which includes the driver (choose the 32bit version).

You might also be interested in