PowerBuilder Authors: Chris Pollach, Yeshim Deniz, Jayaram Krishnaswamy, Kevin Benedict, Avi Rosenthal

Related Topics: PowerBuilder

PowerBuilder: Article

The Little PowerBuilder App that Grew

PowerBuilder provides a powerful environment for creating end-user applications whose primary purpose is data entry & reporting

This article will describe the development of a fairly large (over 4,000 users) one-man software business, selling an application developed with PowerBuilder. I'll touch on a number of technical issues I encountered in the development of the program and the business.

How the Business Got Started
The DONATION program is used by small to mid-sized charities and churches, mostly in North America, to track their donors and donations, and to issue charitable receipts. The first version was actually written in C, in 1994, to fill a gap at my own Quaker Meeting, after a commercial program we had bought started falling apart (no referential integrity). I decided I could write something better. By 1999, it was time to create a Windows version, and the PowerBuilder version was born.

Having put so much work into it by this time, I felt there was no point having only one organization use it, so I put it up for free download and use on a web site. At that point I had a regular programming job and had no desire to make a business out of it. A few years later, I started inviting voluntary contributions for it, but that never did any more than pay my expenses for hosting, software, etc. After 8 years of giving it away for free, there were over 4,000 users.

In 2007, I thought I would like to open source the application, partly to provide a way for it to continue to exist if anything should happen to me, like being run over by a truck! PowerBuilder did not seem ideal for an open source app - too few programmers, plus it's a bit expensive. So, I took a three-month leave of absence from my job, and started a .NET port.

Two months in, I was less than halfway done, and could see that although .NET's database access capabilities had improved significantly, they were nowhere near matching PowerBuilder's. Visual Studio didn't even include a report builder whose runtime could be distributed as part of an open source app. So, after serious reflection, I decided to abandon the port (and the open source idea), go back and continue development with PowerBuilder, quit my job, and start a business with DONATION. I was so relieved to have a powerful, comprehensive and fast development environment back, not to mention one where I didn't have to wait for compiles to test small changes.

The business was launched by announcing to all users that while they were welcome to keep using their current versions for free, future upgrades and support would require a small payment, with a discount being given to existing users. Fortunately, many users paid right away, and the business continued to grow from there.

Issues with SQL Anywhere / Adaptive Server Anywhere
For quite a few years, the program used Sybase SQL Anywhere / ASA as its database. It was in most respects perfect for this use - a great embedded DB, requiring no administration, and rock solid. However, there were two problems.

The first was that the runtime version that could be freely distributed with PowerBuilder applications did not allow any Data Definition Language to be used. As a result, any time I had to make changes to the database structure, like adding new fields to tables, I had to go through a rather convoluted and scary process. First, create a new empty database with the new fields. Then, add code to the program, using Pipelines, to convert from the previous database structure to the new one. Finally, make a new version of my installer that installed the new empty database, and have the first run of the application do the conversion.

Although I could have sold copies of the full ASA to users to eliminate this limitation, this was not an option when the program was free. Even when the program became commercial, the price was so low that adding in the price of an ASA license did not seem to be a reasonable option. (Plus, it would have eliminated the option of giving a free 60-day evaluation period, which I do.)

The other problem was an odd one. Periodically, users' ODBC data sources that had been installed by the program's installer for the ASA DB just stopped working, for no apparent reason. Deleting the data sources and rerunning the installer sometimes fixed it, and sometimes didn't. Sometimes, the information about the driver also had to be removed directly using the Registry Editor before a reinstall would fix it. And very occasionally, nothing I could do would fix it, and the user would have to give up and use the app on a different computer.

Taking these two points together, I finally decided as part of a significant relaunch after abandoning the .NET port to switch to an open source DB with an embedded option. I chose Firebird SQL. It has proven to be a very capable and solid database, though its SQL dialect does have a few weaknesses in comparison to that of SQL Anywhere, such as far fewer built-in functions. Also, it does not support UPDATE statements with FROM clauses, so UPDATEs involving data from multiple tables have to use subqueries as columns' values. The server version of Firebird was also eventually used to provide a multi-user version of DONATION.

Working Around Some PowerBuilder Limitations
DONATION uses PowerBuilder's built-in DataWindow (DW) Sort and Filter dialogs, and until recently also used its DW SaveAs dialog, to give users these capabilities. You can specify a help file and help topic to be used in a Help button on those dialogs, which is extremely helpful since they are a bit techie for end users. Unfortunately, only old-style WinHelp files (*.hlp) can be used, not the more modern HTML Help (*.chm) files. Starting in Windows Vista, Windows no longer comes by default with the capability to display WinHelp files. I am a bit amazed that this still has not been fixed in PowerBuilder, despite being identified as a problem quite a few versions ago. As a result, I have to distribute both a WinHelp help file (for use in those three dialogs) and an HTML Help file (for use everywhere else in the program) with my application.

An annoying weakness of the DW SaveAs dialog is that it doesn't return the filename or file type that the user saved. As a result, it's impossible for an app to do things like offer to open a file saved in Excel format in Excel for the user. Also, if you aren't using one of PowerBuilder's two ways of saving PDF files, the PDF SaveAs option just silently fails. Providing my own SaveAs window allowed me to limit the types to those that I thought would most likely be used by the program's users, and also do things like use a third-party tool DW2XLS (see sidebar) to export almost perfectly formatted versions of reports to Excel.

Speaking of PDF, neither PDF option provided by PB seemed sufficient for DONATION's needs - one required end users to separately download GhostScript, something unrealistic for my users (many of whom are not computer experts), and the other just doesn't work for some report types. As a result, I ended up including a commercial PDF printer driver with API capabilities into the application (novaPDF SDK - see sidebar), which mostly works very well.

Mail Merge
The application required mail merge capabilities for users to send correspondence, including thank you letters to donors about their donations, and to allow users to format their own charitable receipts if they didn't like the built-in receipts in the program (which were normal PB reports).

For years this was done in DONATION by controlling Microsoft Word or WordPerfect via OLE. This was awkward and didn't provide a good user experience because it involved going in and out of the program, and using another UI that they might not be familiar with. (They would probably be familiar with their word processor, but not necessarily with its mail merge features.)

In addition, because I was using the mail merge features in those word processors, there was no way to do anything like sub-reports, which were optimally required for the charitable receipts. (Many users, especially in churches, want a main section describing the total donation amount, for the government, and a second section, for them to keep, listing the details - date, amount and donation category - of each donation.)

To work around these issues required taking another approach, with some form of embedded word processor that could be controlled with an API, to do the merging programmatically. I looked at some commercial options, such as TX Text Control, but ended up with a much simpler solution: have the merge files be HTML files, edited using Internet Explorer's Design Mode.

Design Mode is a little-known feature of IE (at least, it was unknown to me). Activating it turns IE into a relatively simple but still relatively capable HTML editor. You embed an IE control into a PB window, add some menus and toolbars that activate functions in IE's OLE API, and you have something that works really well. Fortunately, there is a freely usable PowerBuilder example of doing this, at http://www.topwizprogramming.com/freecode_webbrowser.html.

After enhancing that to add mail merge features, including special mail merge fields that handled the required subreports, everything worked extremely smoothly (see Figure 1). For cases when the editing capabilities of Design Mode were insufficient, an option was given to edit the HTML file in MS Word. (The editor window's activate event is used to check for the file being saved externally and prompt to reload it.)

PowerBuilder provides a powerful environment for creating end-user applications whose primary purpose is data entry and reporting, such as DONATION. It allows me to be very fast and responsive about fixing bugs and creating new features needed by the program's many users, and to design an application usable even by users who consider themselves to be fairly computer-illiterate.

More Stories By Dan Cooperstock

Dan Cooperstock is the owner and sole staff person of Cooperstock Software, which creates and sells the DONATION program from www.Software4Nonprofits.com. He has been a professional programmer for nearly 30 years, working for a range of employers, including both small and large software companies, and financial institutions. Although his income as a one-man software business is lower than it was as an employed programmer, and he doesn’t get to do as much programming (you can’t keep forcing features on users!), he finds the job satisfaction greatly outweighs those other factors. He has used PowerBuilder since version 5.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.