Welcome!

PowerBuilder Authors: Chris Pollach, Avi Rosenthal, Yakov Fain, RealWire News Distribution, Al Soucy

Related Topics: PowerBuilder, Wireless

PowerBuilder: Article

Appeon Developer Configuration

Tips and techniques

Have you ever used a datastore that ran without a problem while you were developing your application, but once you've compiled it stopped running? Let me tell you that's a difficult bug to fix.

I remember it so well. I kept going back and forth. How in the world could the DataWindow work at design time yet not in the executable? I remember that I checked the return value of the datastore. I finally noticed that the datastore returned a -1. That's such a strange thing.

The datastore returns the number of rows that were returned or a -1. The help files used to say that a -1 was in case of 'an error'. It goes into a lot more detail in version 12.5 but still falls somewhat short of giving you the whole answer.

Here it is...

If you set the dataobject property of a DataWindow or datastore object, then at runtime PowerBuilder will be unable to find it. You will get a return value of -1.

Let me be clear. Take a look at the following code:

datastore lds_employee_list
lds_employee_list = create datastore
lds_employee_list.dataobject = "ds_employee_list"
lds_employee_list.setTransObject(sqlca)

long ll_num_rows

ll_num_rows = lds_employee_list.retrieve()

I'm sure that you've written code like that before. The subject of this article is found in the third line. In that line we set the dataobject property of the newly created datastore. Oh let's step back just a little. In this example I am assuming that you created a new DataWindow and named it ds_employee_list. You'll be able to see it right there in the library painter or in the system tree.

Then in some appropriate event you put the code that I just pointed out.

Now while you're running the code through PowerBuilder there is no problem at all. It will work great. But once you compile the code the last line of this script will always leave ll_num_rows holding a -1.

Isn't that strange? Then you go back to running it through PowerBuilder and sure enough, it works fine. So you optimize the libraries and make sure you do a full rebuild and guess what?

It still returns a -1. That just can't be. That's when you go to your boss and utter those fateful words that make you sound like a compete fool...

But... but... it works just FINE on MY machine.

You can't imagine how bosses hate to hear that.

Here's the issue.

When PowerBuilder runs and encounters that third line it goes out and looks for ds_employee_list. First it looks in the current pbl then, if it doesn't find it, PowerBuilder looks through the library list for it. Eventually PowerBuilder will almost always find that DataWindow object and everything is fine.

The problem happens when we are running the executable. When PowerBuilder builds the executable it pulls the DataWindow object into the pbd. It does that when it's looking through the window painter. It doesn't look though the code to identify those DataWindow objects to pull into the pbd.

This means that at runtime our executable will not be able to find the DataWindow object. Ds_employee_list will simply not be available and the retrieve will return a -1.

How do we fix this? We use the PBR file. That's the file where you put your bitmaps so they will be included into the executable and we won't have to deploy bitmap files with the executable. Here's how it works, you specify the pbl that contains ds_employee_list and then the DataWindow name in parenthesis.

my_app.pbr
C:\images\hand.ico
c:\images\exit.bmp
c:\devel\my_app\my_pbl(ds_employee_list)

Then, in the project painter you specify that my_app.pbr is your PBR file.

Okay, our mystery is solved, right?

Well, no.

The problem came back when I started using Appeon. It was just a bit more complex though. Now the application works at design time. It works when running the executable, but when running in the browser I get that -1.

A little research taught me that Appeon doesn't support the PBR file.

How do I get that DataWindow object where it needs to be?

Appeon has a button called Configuration. When you click on it you get the Appeon Developer Configuration. Look at Figure 1.

In the Appeon Developer Configuration you need to select the application that you are currently using. Then click on Edit. That will take you to Figure 2, The Application Profile Configuration. This is a tool with which you really need to become familiar, for now though, click on the 'Additional Files' tabpage. That will give you Figure 2.

Note the highlighted line. It specifies my appeon_mdi.pbl. This tells Appeon that when you deploy your application it should make all of the DataWindow objects in that pbl available for dynamic DataWindows. It is in fact, similar to the PBR for DataWindows.

Oh yeah, the PBR file also specifies bitmaps, icons and the like. That is handled on this tabpage as well. Look at the group box that says Deploy Image Files. If you specify a folder then Appeon will look in that folder and bring in the bitmaps, icons, jpg, png, and other resource files.

Just so you know.

More Stories By Richard (Rik) Brooks

Rik Brooks has been programming in PowerBuilder since the final beta release before version 1. He has authored or co-authored five books on PowerBuilder including “The Definitive DataWindow”. Currently he lives in Mississippi and works in Memphis, Tennessee.

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.