PowerBuilder: Article

'Bag O' Tricks'

'Bag O' Tricks'

With Halloween just around the corner, I thought I'd give you some of the "tricks and treats" that I've collected over the years for PowerBuilder, InfoMaker, and Sybase ASE.

Horrors! You've just finished a slick bit of coding in your user object, but it's 6:00 p.m., time to head out the door; the Raider game just started, no time for a full backup right now! Then your boss asks you to copy the "latest version" of the PB Development Libraries for Project X that Horatio worked on over the weekend. That's right, Horatio, the one who writes the crummiest code on the planet. Gads! No time for a full backup here either! Never fear, we have an answer...

'Dave's Cheap Backup'
While working in the Library Painter of either PowerBuilder or InfoMaker, right-click on a library (.PBL). You should get a list of options, as shown in Figure 1. Select "Optimize" and wait a few seconds. Gee, that was cool Dave, it did absolutely nothing. Ah, but do it again grasshopper. This time you'll get a strange message box, as shown in Figure 2.


A backup file exists? We didn't back anything up. Yes you did, but you didn't know it. Way back when, the PowerSoft engineers were kind of chicken. The "Optimize" defrags your library, so they decided that it might be a good idea to back up the library first. Only problem is they left out the code for removing this backup file after the defrag. Aha! We can put that to use as a short-term backup of our own.

If you open up the directory where you store your .PBLs using Windows Explorer, not the Library Painter, you'll now see a new file. It has the same prefix as your library name, but ends in .BAK. Welcome to ancient history, the DOS backup file, which is nothing more than a copy of your file with a .BAK extension. All you need to do to use this file in the future is to rename the file, replacing the .BAK with .PBL, and you're back in business.

Okay, so it isn't the best or brightest, but it works and it's freeShence, Dave's "Cheap" Backup.

Changing a Grid DW to Tabular and Back Again
From the PowerPanel in PB 8, right-click on a grid or tabular DataWindow object. You'll have an option of "Edit Source" (pre-PB8 folks will have to use the export/import feature). In the DataWindow properties, you need to change one item, the "processing" parm from a 1 (grid) to a 0 (tabular) or the other way around. Now, before you get all excited, keep in mind this only works for tabular versus grid. You can't go changing a tabular into a crosstab or something crazy like that, but...if you have a lot of grid DataWindows that you'd like to switch to tabular, here's an easy workaround instead of re-creating beaucoup reports just to make them tabular/grid. The following is a shapshot of the code in question:

release 8;
datawindow(units=0 timer_interval=0 color=16777215 processing=1 S

Get Rid of Those Quotes in Your SQL
It seems that I'm not the only one who absolutely can't stand those quotes around my SQL that PB (by default) puts into SQL Syntax. You don't have to live with them. Simply right-click on any database connection, select the "Syntax" tab, and uncheck the box for quotes, as shown in Figure 3.

'Flower Boxing'
The last item is a pet peeve of mine. I like my code documented. Now, I'm not a pinhead and document every line of code, just enough to help me remember 18 months later what the heck I was doing. The box of comments in Listing 1 is a good "template" to use for your objects. I actually put this box at the end of the SQL in my DataWindows using Syntax mode (I rarely use Graphic mode anymore when in the SQL Toolbox). This helps me keep track of changes and, if necessary, roll back to a previous version.

By the way, us old mainframers (yes, I admit to being one way back when, ancient dinosaur that I am) used to call these documentation headers "flower boxes" because they were bordered with asterisks (which kind of looked like hippie flowers of the '60s) on an old IBM green-screen monitor. Been calling them that ever since.

More Stories By David Hart

David Hart is a former Sybase Tools and Database Instructor. He is a certified PB developer and certified ASE DBA from Rancho Cucamonga, CA. He is currently on contract assignments in Southern California.

Comments (1)

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.