| By Richard (Rik) Brooks | Article Rating: |
|
| January 1, 2013 04:00 PM EST | Reads: |
1,494 |
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.
Published January 1, 2013 Reads 1,494
Copyright © 2013 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
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.
- Cloud People: A Who's Who of Cloud Computing
- New Relic Q1 2013 Blazes Past Growth Targets and Reaches 40,000 Active Customer Accounts
- GDS International Confirms Unprecedented Delegation for Upcoming Next Generation Telecoms Europe Summit in May
- AWS Going into a New Line of Work
- Cloud Expo New York: Using APIs for Better Business Partnerships
- Google Compute enters the IaaS market
- Agile Solutions for Cloud, Big Data, Mobility Services
- Apple’s Key Rubber-Band Patent Found Invalid Again
- How to Re-imagine Your Business for a Mobile World
- The Cloud Delivers a New American Workforce
- 910Telecom to Exhibit at Cloud Expo New York
- Component Models in Java | Part 2
- Cloud People: A Who's Who of Cloud Computing
- New Relic Q1 2013 Blazes Past Growth Targets and Reaches 40,000 Active Customer Accounts
- North America and Asia Account for Highest Proportion of TD-LTE Network Deployments, Direct Carrier Billing Accelerates Revenue Growth for CSPs
- GDS International Confirms Unprecedented Delegation for Upcoming Next Generation Telecoms Europe Summit in May
- AWS Going into a New Line of Work
- Register for the 2013 FOSE Conference
- Cloud Expo New York: Using APIs for Better Business Partnerships
- Apple Ordered to Pay VirnetX $333K a Day
- Google Compute enters the IaaS market
- Agile Solutions for Cloud, Big Data, Mobility Services
- Nielsen to Present at Upcoming Conferences in March
- IBM Picks Mobile for Its Next Big Growth Play
- Where Are RIA Technologies Headed in 2008?
- Should RIM BlackBerries Be Rented?
- Has the Technology Bounceback Begun?
- Trump's Apprentice Runner-Up Rebecca Jarvis Has $150,000 Job Offer From SYS-CON Media
- "Mobile Web 2.0" – How Web 2.0 Impacts Mobility & Digital Convergence
- Ringback Tones
- Microsoft and Sprint Collaborate on Mobile Search
- Mobile Music Gets Boost From New W600 "Walkman Phone"
- i-Technology Blog: Zero-Cost Telephony, the 6-Ton Elephant in the Telco Room
- Java Edition of Windows Live Messenger for Mobile Launched
- Alcatel + Microsoft = Internet TV Over IP, a.k.a. "IPTV," Coming Soon To a PC or TV Near You
- Cloud People: A Who's Who of Cloud Computing


























