PowerBuilder Tips, Tricks, and Techniques

Berndt Hamboeck

Subscribe to Berndt Hamboeck: eMailAlertsEmail Alerts
Get Berndt Hamboeck: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

PowerBuilder: Article


Organize your flights with PocketPB

As you may already know, Pocket Outlook is an application for managing diaries and commitments and it's included with all Pocket PC devices. From the beginning the Pocket Outlook tools, such as Calendar, Contacts, and Tasks, which you'll also find within the (flash) ROM of your device, did not provide all the functionality required by users, such as the search facility, so the decision was made to use an object store (a database) to store all timetable events, deadline information, and contacts there.

Access to this so-called Pocket Outlook database is carried out via the Pocket Outlook Object Model (POOM). This model also ensures that information entered using any application that uses POOM is accessible via the standard Pocket PC management tools or any other tool or application using POOM. This tight integration provides a clear and usable system for the users and Pocket PowerBuilder developers.

What Is It Good For?
I have to say that when I first saw the "New features" list of Pocket PowerBuilder a long time ago I thought: "What can we do with it?" This shows that I was pretty new to serious development for handheld devices. It's great that we are able to connect to databases and display data with the DataWindow technology and it's also spectacular to synchronize changes from a handheld device to a desktop database, but there is more we can do with these small devices in the palm of our hand. I'll provide some examples that came immediately to mind when I was thinking about how Sybase Pocket PowerBuilder would enable us to write cool, new applications:

  • A birthday application in which you enter the birth dates of your family and friends so that you'll never forget to call them (if you're married you'll know why this is the first on my list). The dates will be exported to the calender and our handheld will display the date on the today screen.
  • A medication reminder application that helps you remember appointments, when to take pills, and more.
  • Store information in your handheld regarding where and when your favorite football or soccer team is playing.
  • A stock application in which you could export to your calendar the date for the shareholders' meeting or the dates when the dividend is automatically paid.
  • An application where you plan and keep track of your exercise program. Plan the days when you want to run or go to the gym and export these dates so that they will display on the today screen of your handheld.
  • A flight planner application - enter flight dates and look them up in your handheld's calendar.
In this article we investigate the Pocket PowerBuilder implementation of POOM, the Pocket Outlook Object Model. Thanks to the guys in PPB engineering we have a 4GL RAD interface to something that causes even the best .NET developers problems and to break out in a cold sweat.

With POOM we can create excellent Pocket PowerBuilder applications that take advantage of the task, contact, and appointment features of the Pocket PC OS. Let's face it, the last thing you would want to do is redevelop that feature set in your Pocket PowerBuilder applications!
?Ian Thain,
Pocket PowerBuilder Editor

There are a lot of applications that have to be written, and now we are able to write them with Pocket PowerBuilder. I'll show you how I used the new POOM feature to write the last one on my list, the flight planner application, but before we dive into the source code we should take a look at the new objects provided for development by Pocket PowerBuilder.

The POOM Implementation
Starting with Pocket PowerBuilder 1.5 we have some new objects that we'll use to implement the features we need to write Personal Information Manager (PIM) applications.

There are several new objects that I'll describe now and some of them we'll be using in our example. You can see how these objects are connected in Figure 1.

The Pocket Outlook Object Model
The POOM object is used to tightly integrate our Pocket PowerBuilder applications with the Pocket PC. It serves as an object store for the Pocket PC contact manager and appointment calendar. The POOM object will be used to manipulate tasks, contacts, and appointments programmatically. It's the main object that provides access to the other POOM-related objects. It has a login function that has to be used to connect to the internal POOM database; we'll be able to add or remove appointments only after we logged in using this function. The function add is used to bring new appointments, contacts, or tasks into your handheld so they can be used by any other POOM-enabled application.

The POOMAppointment Object
The POOMAppointment object lets you add or remove recipients, and get or set appointment recurrences, but we must use functions on the general POOM object to add or remove appointments, such as:

  • GetAppointment: Obtains a single appointment using an index
  • GetAppointmentFromOID: Obtains a single appointment using a specific object identifier (OID)
  • GetAppointments: Obtains an array of appointments, where all your appointments are returned, or are meeting specific criteria
This object also uses the POOMRecipient object, which is used to define one or more recipients of appointment notifications, and the POOMRecurrence object, which is the one to use if you would like to repeat your appointment (or task); for example, you don't want to miss the latest episode of "Stargate" every Wednesday at 8:15 p.m. (at least here in Austria) on TV.

The POOMContact Object
The POOMContact object lets us create, copy, and display contacts through the POOM object, which means that again we must use functions on the general POOM object to add or remove contacts, as you'll see in our example. These functions work in a similar way to the ones provided for the appointments, but will return contact information (GetContact, GetContactFromOID, GetContacts).

The POOMTask Object
Only after you log in using the general POOM object can you add or remove tasks. The POOMTask object lets you copy and display tasks, and get and set task recurrences, but again we must use functions on the general POOM object to add or remove tasks (GetTask, GetTaskFromOID, GetTasks).

The Flight Planner
Let's think about what such an application should bring the user and which of the new objects we'll have to use. From our Flight Planner application (see Figure 2) we expect the following features:

  • Display the names and contact information of different airlines. This is a must; when you travel a lot sometimes you have to change your flight due to unforeseen circumstances.
  • We want to enter flight information, but what should we store there? If you think about it there's a lot of information that you might need:
    -Destination to/from.
    -The airline you're flying with.
    -The time of the flight and when someone will be able to pick you up.
    -Whether you have an electronic ticket, which you can get at the airport, or should you bring it with you (very handy if you book your flights three months in advance like I do and use different airlines and airports).
    -How much does the flight cost; very useful for figuring out your traveling costs weeks later, or for creating a report for your expenses.
    -The amount of luggage you are allowed to take with you.
    -We might need a booking number if there are problems at the airport, or if you need to call the airline to change or cancel your flight.
    -Time zone information - if you are opening the system configuration on your handheld and choose a different time zone, all your appointments are changed accordingly based on the new time zone. This is usually no problem, but if you're booking a flight it's already booked for the correct time zone, so it's not a good idea if your device moves your flying time around (it might not be such a problem if you're at the airport three hours early, but I wouldn't like to see your face if you're two hours late). Unfortunately there is no way to change the default behavior.
  • We want to search for one or more (or all) the flights we have booked.
  • We want to create a report, such as "How much did we spend last year to fly around?"
Poom Stuff in Action
Let's dive into the actual implementation; I'll pick some lines from the interesting source code for this article; the full implementation is available on CodeXchange at the Sybase Web site in the PocketPowerBuilder section. Okay, let's start. First we'll create a new window and then place a tab control on it with four tab pages.
  1. On the first tab page we can define a flight.
  2. The second one searches for our flights.
  3. The third one performs the reporting tasks.
  4. The last one displays our contact information.

More Stories By Berndt Hamboeck

Berndt Hamboeck is a senior consultant for BHITCON (www.bhitcon.net). He's a CSI, SCAPC8, EASAC, SCJP2, and started his Sybase development using PB5. You can reach him under [email protected]

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.