Viewing Contents of datastore in Powerbuilder
Mia Lopez
I am running powerbuilder 11.2 and trying to debug an operation that pulls data from a text file into a datastore. I can set a watch on the datastore and see information about it, but I want to see the actual contents of the datastore. I have seen some suggestions of adding an expression to the watch window and I inserted the following command:
[datastore].saveas("c:\test\[datastore].xls", xls!,true)into the watch window but all I got was a circle with a line through it in red. I checked the directory and nothing was saved. I haven't done PB development in a long, long time and this was assigned to me because I did PB development before. So, how can I dump the contents of a datastore in debug mode? Any and all help is so very much appreciated.
5 Answers
Yes the saveas() tip is a quick way to check what is in a datastore.
But you do not have to add the expression in a watch (because it is likely to replace the data each time the watch is evaluated, or to crash if the datastore is not valid) but in the "quick watch" dialog.
- put a breakpoint after the datastore is supposed to be populated (e.g. after a
retrieve()orimportString()) - run your program
- when the BP triggers, you can make a "right-click / QuickWatch" on the datastore name to display the Quick Watch dialog
- replace the
yourdatastorein the expression field byyourdatastore.saveas("c:\temp\somefile.xls", excel5!, true)then click "reevaluate" - if the export is successful you should see in the Quick Watch dialog that the returned value is
1.-1tells there is a problem, like a wrong path or the result file already opened (locked).
You can also use text! instead of the excel5! value to see the data if Office is not installed in that box. excel5! is a pretty old format that is widely known by viewers, but excel8! or xlsx! (after PB11.5.1) is equally acceptable.
If your location to write the file is c:\test the syntax is "c:\test\"
So the proper entry in the watch window would be:
ids_mydata.saveas("c:\test\mydata.xls", Excel!, true)This saves the data currently in the 'ids_mydata' datastore to an Excel file named 'mydata.xls' in the folder 'test' on your C drive.
You have a syntax error in your expression. Save as type Excel must be Excel! or XLSX!.
Saving as Excel 2007 and later (requires .NET 3.5 or later):
[datastore].saveas("c:\test[datastore].xlsx", xlsx!,true)Saving as Excel format:
[datastore].saveas("c:\test[datastore].xls", Excel!,true) 2 The SaveAs is not a debugger watch expression. You have to add it to your code and put a breakpoint on the line following it. When it hits the breakpoint, open the file in Excel.
1You might find it helpful. The link explains how to access data from different buffers.
Anytime during debug you see the red circle in watch window where you evaluate expression, that means your app crashed already. You have to restart debugger.
Better use TRY CATCH statement (and that does not prevent from crashing in debugger i guess).
1