0% found this document useful (0 votes)
385 views44 pages

Guest Editorial: A Brighter Future For PowerBuilder and Sybase

A Brighter Future for PowerBuilder and Sybase Distributed Ways: Developing Jaguar Business Components

Uploaded by

Leo Vasquez Blas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
385 views44 pages

Guest Editorial: A Brighter Future For PowerBuilder and Sybase

A Brighter Future for PowerBuilder and Sybase Distributed Ways: Developing Jaguar Business Components

Uploaded by

Leo Vasquez Blas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

JOURNAL FOR PEOPLE INTERESTED IN CLIENT/SERVER AND INTERNET / INTRANET

DEVELOPMENT WITH POWERBUILDER, POWERSITE, POWER++ AND POWERJ


JULY /AUGUST 1999

PRICE: US$ 7.50

A BRIGHTER FUTURE FOR


POWERBUILDER AND SYBASE

Contents
Guest Editorial: A Brighter Future for
PowerBuilder and Sybase
by William B. Heys on Page 1

The Big Question:


Is Your PowerBuilder Application Ready
for Windows 2000 ?
by Roy Kiesler on Page 3

COM Knowledge:
COM+ Features
by Alan Walsh on Page 8

Distributed Ways:
Developing Jaguar Business Components
by Sean Flynn on Page 12

EASy Does IT: Migrating Applications


from Distributed PowerBuilder to
Enterprise Application Server 3.0
by William B. Heys on page 16

The Real World:


Datastore Update Problem and Solution
by Gene Steiker and Alan Staub on Page 21

PFC Place:
Multi-Select Treeview
by Boris Gasin and Roy Kiesler on Page 25

Share Aware:
Sharethe Globals

VOL. 6 / ISSUE 4

by William B. Heys
The single most important event in my career was
learning PowerBuilder 1.0 almost eight years ago.
Since that time I have focused my career almost
exclusively on Powersoft (and subsequently Sybase)
technologies. I have experienced many emotions:
pleasure, challenge, frustration, and disappointment.
For the first few years I believed PowerBuilder was
truly the best of breed tool for developing client/
server applications.
Technology is changing at a rapid pace. Not that
long ago, nobody was thinking about Y2k or
developing applications for the Web. What a
difference two or three years can make.
Like many of you, I have been disappointed in
Sybases marketing message and technology over the
last couple of years. I thought the adaptive
component architecture message was too abstract
and not focused enough on solutions that clients want
and need.
More recently, the message seemed to be wait for
the next release. I jumped on the Distributed
PowerBuilder bandwagon in PowerBuilder 5 only to
discover it wasnt ready for prime time. The message
was Its a first step, wait until the next release.

reviewed by Arthur Hefti on Page 33

When Jaguar was introduced, I desperately wanted to


switch from DPB to Jaguar. But you couldnt deploy
PowerBuilder components to Jaguar in PowerBuilder
6.0 or 6.5, and Jaguar 2.0 couldnt run native
PowerBuilder components. The message was wait
until the next release.

Advertiser Index on page 34

Well the next release is here. PowerBuilder 7.0 has a

by Jon Credit on Page 30

Little Helpers:
EncryptX 1.3 by InnerDynamics Software

User Group News


(Continued on page 2)

beginning on page 36

Page 1

Impressum

(Continued from page 1)

completely new user interface designed to make


development easier. The real good news is how
easy it is to create and deploy PowerBuilder custom
classes as native components in Enterprise
Application Server 3.0
The future is the World Wide Web. There will be a
tremendous demand for business-to-business and
business-to-consumer applications for the Web.
Applications for the Web require an application
server.
Sybases Enterprise Application Server 3.0 offers
many important features not available from other
vendors such as Microsofts MTS. EAS is more
scaleable, has better support for failover protection,
and supports Java, CORBA, COM, and native
PowerBuilder components. MTS is a Windowsonly solution that is less scaleable and only
supports COM.
For the first time in a few years, I am beginning to
feel excited about Sybase again. Superior
marketing and a marvel of technology known as
the DataWindow made PowerBuilder king of the
mountain. Today we can have DataWindows
everywhere. We still have the familiar client/server
DataWindow, but now we have the DataWindow
ActiveX, the DataWindow Plug-in, the Java
DataWindow, and the PowerSite DataWindow
design time control for HTML.
In recent issues of PowerTimes, Carson Hager
contributed a column called EASy Street. In this
issue, I have written an article called EASy Does
IT! You can draw several inferences from this
title. Building a distributed PowerBuilder
application is EASier with Enterprise Application
Server than with Distributed PowerBuilder. The
message is no longer EAS will do it, but rather
EASy Does IT Now!!!. Try PowerBuilder 7 and
Enterprise Application Server 3.0. I think you will
like them.
Bill Heys
Whittman-Hart, Inc.
Lexington, MA
USA

PowerTimes is an international PowerBuilder Journal


published 6 times a year mainly destined to PB User
Groups worldwide. If your User Group does not subscribe to PowerTimes and you would like to receive it,
then you can subscribe to it on an individual basis.

Contact addresses:
Editor:

Rolf Andr Klaedtke


Bchlistrasse 21
CH-8280 Kreuzlingen / Switzerland
Fax: ++41 - (0)71 - 670 01 71
e-mail: [email protected]

Co-Editor:

Mark A. Lansing
Eichmatt 17
CH-6343 Rotkreuz / Switzerland
Fax: ++41 - (0)41 - 790 74 79
e-mail: [email protected]

On the web:

http://www.powertimes.com

Column responsibles:
Little Helpers:

Arthur Hefti
[email protected]

PFC Place:

Boris Gasin
[email protected]

Know How:

Bernie Metzger
[email protected]

Distributed Ways:

Sean Flynn
[email protected]

COM Knowledge

Alan Walsh
[email protected]

Subscription rates:
Individual:
User Group:

US$ 45 per year


US$ 750 per year

For user group subscriptions, the group has the right to


distribute PowerTimes to their members in an electronic
or printed form at no extra charge ! PowerTimes is
produced as an electronic document in Adobe Acrobat
format.
Disclaimer:
Articles or opinions published in PowerTimes do not
necessarily reflect the opinion of the editorial team.
They reflect the opinion of the submitter. We assume
that the copyright of all submitted articles is owned by or
granted to the submitter. We must decline every responsability regarding technical correctness or truth of
submitted articles and opinions.

Page 2

IS YOUR POWERBUILDER APPLICATION READY FOR WINDOWS 2000?


by Roy Kiesler

Introduction
On Tuesday, June 15, Microsoft announced the
final release of the Application Specification for
Windows 2000, dubbed the Windows 2000 Logo
Program.

There are currently two Windows 2000 logo classes:


Windows 2000 Professional (for client applications)
and Windows 2000 Server (for server and distributed applications.)

Ladies and Gentlemen of the Class of 991:


Wear sunscreen!
If I could offer you only one tip for the future,
sunscreen would be it. The long-term benefits of
sunscreen have been proven by scientists, whereas
the rest of my advice has no basis more reliable than
this specification document, which is subject to
change until Windows 2000 (SP1?) ships. I will
dispense this advice now.
Figure 1, Windows 2000 Certification Logo

Thin Is In
But fat isnt out yet. Windows applications are
still created every day, with a richer set of features
than ever before. Surprisingly, though, these rich
clients have a significantly smaller footprint.
Thanks to tighter integration with new operating
system services, some of which are already available
under Windows 98/NT, these applications are trimmed down, leaner and meaner than their ancestors.
Take the newly released Office 2000 suite for example; after migrating from Office 97, I was pleasantly
surprised to find out that a standard installation of
Word, Excel, PowerPoint, Outlook and FrontPage
now consumes only 137MB of my disk space. The
previous installation of Office 97 used more than
200MB of disk space.
If you are serious about Windows programming,
you should familiarize yourself with the new application specifications, regardless of your intention to
obtain the logo for your application. The Microsoft
Windows Logo Program has nothing to do with the
strategy behind the application or its feature set. It
helps developers do a good job of implementing
functional specs, keeps them informed about the
latest innovations and provides a checklist for producing cutting-edge software. It also offers practical
suggestions on writing good Windows applications
that provide a consistent user experience and reduce
support and training costs.

In this article, I will review a few of the areas


covered by this new design guide for building business applications.

The Basics
Windows Fundamentals
Provide 32-bit-only components
Do not add to or modify win.ini, system.ini, autoexec.bat or config.sys
Provide HTML-based help system

To begin with, your application should consist of


32-bit-only components. Special circumstances may
exist, which mandate the use of 16-bit code, however, for the purpose of this article, we will assume
none exist.
Is your application making changes to win.ini or
system.ini files? Perhaps to dynamically change the
default printer, or to perform some other shell
related action? This common practice that started in
the days of Windows 3.x, is no longer allowed.
Changes to the shell or system settings can only be
made through appropriate API calls or by accessing
the system registry.
If you haven't done so yet, you should start converting your RTF-based WinHelp system to the new
HTMLHelp format. The HTMLHelp Workshop tool

Page 3

(Continued on page 4)

User Settings and System Policies

(Continued from page 3)

is freely available from the Microsoft MSDN web


site. Other commercial tools, such as RoboHELP
from BlueSky Software are also up to the task.

User Interface
User Interface Fundamentals
Support standard system size, color, font, and input
settings
Provide documented keyboard access to all features
Ensure compatibility with the High Contrast display
option

The UI standards have not changed much with the


new version of Windows. The same rules of thumb
still apply: maintain consistency with the operating
systems UI, integrate with the system shell as much
as possible and be usable and friendly.

System Fonts Windows 2000 uses Tahoma as


its system font, instead of MS Sans Serif which
is used by Windows 95/98 and NT. Tahoma is
a Unicode-compliant font, which had its first
debut in Microsoft Office 97.
System Colors use the following table as a
guide:
Use
WindowText,
25
33554432 (2 )
ButtonFace,
26
67108864 (2 )
AppWorkspace,
28
268435456 (2 )
WindowBackground,
30
1073741824 (2 )

User Settings and System Policies


Default to the MyDocuments folder for saving documents created by the user
Adhere to all system policies

It is recommended that your application defaults to


the MyDocuments folder for saving documents
created by the user. For example, if you have a
report window that enables the user to save the
DataWindow contents to a file, you should provide
the MyDocuments folder path to the GetFileSaveName function. Note, though, that the MyDocuments folder is a system folder, whose actual
path may change from one user to another. In order
to get the exact path of this folder, you will need to
call the following API function:
FUNCTION boolean SHGetFolderPathA( &
ulong
hWnd, &
long
nFolder, &
ulong
hToken, &
ulong
dwFlags, &
REF string lpszPath &
) LIBRARY "shfolder.dll"
CONSTANT long CSIDL_PERSONAL = 5
CONSTANT ulong SHGFP_TYPE_CURRENT =
String
Ulong

Do not use
Black,
0, RGB(0,0,0)
Light Gray,
RGB(192, 192, 192)
Dark Gray,
RGB(128, 128, 128)
White,
RGB(255,255,255)

High Contrast Display Compatibility this


option increases screen legibility for users with
vision problems. As Figure 2 illustrates, the
PFC Examples application correctly uses system colors, which allow its interface to remain
consistent in high contrast display.
Notice, on the other hand, that the PFC dropdown calendar in Figure 3, is using black fonts
for the weekdays display, instead of using the
WindowText system color (see table above).
The result is that the font color remains unchanged on the high contrast black background, thus rendering the text invisible.
Keyboard Shortcuts should be used across
your application, including in free-form DataWindows. Users who perform intensive data
entry tasks will thank you. While you are at it,
double check your menus to make sure that
each menu item is assigned a shortcut.

ls_mydocs, ls_filename
lul_token

SetNull( lul_token )
ls_mydocs= Space( 260 )
IF NOT ShetFolderPathA( &
Handle( this ), &
CSIDL_PERSONAL, &
lul_token, &
SHGFP_TYPE_CURRENT, &
ls_mydocs )
THEN
// handle the error
END IF
ls_mydocs += "myreport.psr"
GetFileSaveName( "Save", ls_mydocs, &
ls_filename )

Policies are collections of system and user-level


restrictions, used by network and system administrators as part of the Zero Administration Windows
initiative. They include such restrictions as disk and
folder quotas, registry access rights, removing the
Run command from the Start menu, etc. Your
application should handle all these restrictions and
gracefully degrade when necessary.

Power Management
OnNow/ACPI Support
Respond to operating system sleep and wake requests and notifications properly

The Advance Configuration and Power Interface


(Continued on page 6)

Page 4

GET YOUR WEB APPLICATIONS


ROLLING, WITHOUT ALL THOSE
PESKY IN - BETWEEN STEPS.

Introducing PowerBuilder 7.0 and Enterprise Application Server 3.0. Together,


they offer the fastest, easiest way to assemble, test, and deploy scalable, thinclient applications for the Web. You not only take advantage of a highly
productive development environment that leverages your existing skill sets
and technology. Youll also deploy more scalable, more secure applications,
from Web to N-tier architectures. It all adds up to the most powerful way
to take your business to the Web. For details on EAServer and PowerBuilder,
call 1-800-8-SYBASE, or visit www.sybase.com/sdn.
1999 Sybase, Inc. All rights reserved. All trademarks are the property of their respective owners.

(Continued from page 4)

Figure 2, High Contrast Display Compatibility

Figure 3, High Contrast Display Incompatibility


(ACPI) reduces power consumption, whether power
comes from a wall outlet or a battery. When the
computer is turned off, it goes into a lower power
state and can then be wakened by a device in the
system, such as the network card, modem, or keyboard.
Windows 2000 compliant applications must participate in the power management process mandated by
the operating system. Applications must be able to

respond to system or user requests to support a


low-power state, and then they must also respond to
wake notifications, preserving data appropriately.
From a programming perspective, this means that
your PowerBuilder application must be able to suspend and resume on demand. Windows 2000 passes
a sleep request to an application using the
WM_POWERBROADCAST message.

Page 6

(Continued on page 7)

If I was a betting man, I would venture to say that


you should be able to get a sneak peek at the Alpha
version of PowerBuilder 8.0, this coming August at
the Sybase users' conference in Orlando, Florida.

(Continued from page 6)


WM_POWERBROADCAST
dwPowerEvent = wParam
dwData = lParam

// ulong
// long

// Power Events
// -----------// Battery power is low
CONSTANT ulong PBT_APMBATTERYLOW = 9
// OEM-defined event occurred
CONSTANT ulong PBT_APMOEMEVENT = 11
// Power status has changed
CONSTANT ulong &
PBT_APMPOWERSTATUSCHANGE = 10
// Request for permission to suspend
CONSTANT ulong PBT_APMQUERYSUSPEND = 0
// Suspension request denied
CONSTANT ulong &
PBT_APMQUERYSUSPENDFAILED = 2
// Operation resuming automatically
// after event
CONSTANT ulong &
PBT_APMRESUMEAUTOMATIC = 18
// Operation resuming after critical
// suspension
CONSTANT ulong PBT_APMRESUMECRITICAL = 6
// Operation resuming after suspension
CONSTANT ulong PBT_APMRESUMESUSPEND = 7
// System is suspending operation
CONSTANT ulong PBT_APMSUSPEND = 4

But trust me on the sunscreen!

References
The latest drafts of the Microsoft Windows 2000
Application Specification can be found on the
Microsoft web site at http://msdn.microsoft.com/
winlogo/win2000.asp.
For more information about the OnNow initiative
and other power management related issues, see:
http://www.microsoft.com/hwdev/onnow.htm and
the Microsoft Platform SDK Power Management
Reference at: http://msdn.microsoft.com/library/
sdkdoc/winbase/power_3v6t.htm.
_____________________________
1

In most cases, your application should always accept this request, unless, for example, it is right in
the middle of a transaction. Unfortunately, PowerBuilder does not yet have a pbm_power-broadcast
event mapped to this message.

Installation
Install/Uninstall
Install using a Windows installer package that passes validation testing
Identify shared components
Install to Program Files by default
Support Add/Remove Programs properly
Ensure correct uninstall support
Publish program information properly in the Start
Menu

In one word InstallShield. Windows 2000 has a


new feature called the Windows Installer Service.
The Installer engine replaces the current setup API
functions. For more information on Windows Installer, visit http://www.installshield. com.

From a column by Mary Schmich for the Chicago Tribune, these


word were the basis for the song Everybody's Free by Baz Lhrmann. The original column can be read at http://chicagotribune.com/news/columnists/schmich/0,1122,SAV9706010178,00.html.

?
Roy Kiesler is a Senior Lead Consultant at
Noblestar Systems in Cambridge, MA, a leading
provider of strategic information technology
business solutions. Roy has been working with
PowerBuilder since version 4.0, developing client/
server applications for the Pharmaceutical,
Financial Services and Tele-communications
industries. He is a member of Team Sybase a
group of highly proficient Sybase/Powersoft
product users, who volunteer their time to answer
questions in various support forums. Contact Roy
via e-mail at [email protected].

Conclusion
In this article, I introduced you to some of the basic
guidelines for developing PowerBuilder applications that are Windows 2000 compliant. Windows
2000 packs a slew of new and exciting features,
which undoubtedly, keep the members of the PowerBuilder developers team very busy, as they work
to make the next major version of PowerBuilder
Windows 2000 compliant.

Roy at the Special Event during the Sybase Conference


in Los Angeles, 1998...

Page 7

COM+ FEATURES
By Alan J. Walsh

Introduction
As I sit here getting ready to load Windows 2000
Release Candidate 1 on my machine, it occurs to me
that it might be high time to talk about COM+, the
latest version of Microsoft's architecture for component development. Many of you out there are now
on the COM and component bandwagon, and the
newest member of the Windows family brings many
changes in this area. Come with me as we take a
brief tour of these changes and what Windows 2000
has in store for application developers.

Some Things Never Change


Well, almost never. Actually there is a lot in COM+
that has not changed - and that's good news for
developers. If you take a close look, you'll see that
the basic conceptual model is the same: components, interfaces, and classes are still a part of
COM+. You'll also find many of the familiar services that actually implement COM are still there.
This is good because it means we still have familiar
support for things like remote interfaces. I even
noticed that DCOMCNFG is still there. And of
course MTS is still in there. In fact, MTS is a big
part of COM+ - although you'll have a tough time
finding any mention of it. More on that later. In
short, Microsoft has done a lot of work to make sure
that the investments we have made in learning
COM are not wasted or lost. So take a deep breath,
be comfortable in the knowledge that you already
know a lot of what you need to know to use COM+,
and let's move on....

Get It Together
More than anything, I think COM+ is about
bringing together a bunch of stuff that has kind of
been floating around separately for a while. Perhaps
the biggest change in COM+ is the merging of
COM and MTS into one cohesive programming
model. Today we really have two models: the COM
model, which gives us the basic stuff like interfaces,
and MTS which adds an API and the plumbing to
support nifty things like distributed transactions, as
well as better support for security and component
management. COM+ has merged the two and we

now have a single API for component development


in Windows 2000. There was a time when the COM
team and the MTS team were actually two separate
groups. Microsoft has since changed that and there
is now one gigantic COM+ team working to provide
developers and administrators with the tools they
need to build DNA (Distributed interNet Applications Architecture) applications.

New Look
Some of most obvious changes to COM are in the
user interface. For example, the MTS Explorer (and
indeed just about any mention of MTS at all) is
nowhere to be found in Windows 2000. Instead, it
has been replaced by the Component Services Management Console snap-in (see figure 1). This is
where both administrators and developers come to
do most COM+ related activities. Administrators
use Component Services to deploy and administer
components, while developers can use it to configure things like security and transaction support.
The user interface is nice, but the COM+ team
worked hard to make sure that all the functionality
in the Component Services snap-in is also available
through scripting. This makes it easier for both
developers and administrators to automate routine
tasks.

New Services
COM+ brings several new services for developing
applications. My personal favorite is load balancing. This is something that COM has desperately
needed for a long time, and unless you wanted to
write it yourself it just wasn't available. COM+
gives administrators and developers the ability to
deploy components on a "farm" of servers and have
client workload automatically distributed amongst
those servers. You designate one server as a component load balancing server (CLB). This machine
acts as a router - all client requests are sent here,
and it is your single point of failure. Microsoft
recommends that you designate a backup CLB server for fault tolerance. The CLB server keeps track
of servers in the farm and forwards the request to

Page 8

(Continued on page 10)

Page 9

(Continued from page 8)

Figure 1, Component Services


the most appropriate server, as illustrated in this
diagram from the Load Balancing Help in Windows
2000:

Load Balancing provides gains in both performance


and fault tolerance, and I am certain that many
developers will take advantage of it in building their
applications. One final note: it is important to keep
in mind that developers must understand how to
develop components that are capable of being load
balanced. The fact that you don't know exactly
which server your component will live on might
have some implications that you will have to keep
in mind as you develop your application. The Platform SDK has detailed information about building
load balanced components

Get in the Queue

Figure 2, Load balancing

Another powerful feature in COM+ is queued components. Microsoft introduced message queue services in the Windows NT 4 Option Pack with MSMQ
(Microsoft Message Queuing). Now COM+ developers have that same functionality available to
them. The idea is that your applications can make
calls to components whether they are online or not.
Requests are sent to a message queue and then
played back when the component is available. As
was the case with load balancing, there are some
restrictions that the developer must take into account when developing queued components. For
example, all parameters must be passed by value
and are in-only. This is an asynchronous kind of
(Continued on page 11)

Page 10

(Continued from page 10)

activity, so you can't have clients sitting around


waiting for out parameters or even return values.
They fire and forget. You may or may not have a
call to use message queues and queued components
in your applications, but it is certainly nice to have
that option. Queued components offer a degree of
fault tolerance that is hard to match if you can
livewith the restrictions that they impose.

Conclusion
In conclusion, you can see that there is a lot that has
improved with the delivery of COM+. It is now
even easier for developers using any language to
build scalable and reliable distributed applications
on the Windows platform. COM+ retains the best
parts of COM and MTS and gives us a host of
powerful new services.

Events
There are times when it would be nice for your
application components to be automatically notified
when something happens. Anyone familiar with
Windows already understands events, and now
COM+ brings events and event services to components. With COM+ events, developers can utilize a
simple publish and subscribe model to allow their
components to be notified when something interesting or important happens. It uses late binding, so
subscribers are identified after the event happens,
and then COM+ sends the notification via standard
COM calls. As with queued components, method
parameters are in-only. The notifier will not be
waiting around to hear back from the client.

?
Alan Walsh works for Indiana University. He can
be reached at [email protected].

IMDB
The last new service that I want to talk about
attempts to solve a problem that developers have
had for a long time when creating server components: how to decrease access time for databases.
COM+ solves this problem with something called
IMDB: In Memory DataBase. The idea is that you
can load a copy of your data into memory either at
startup or at some other time that you decide.
Because the data is in memory, access is extremely
fast. You are only constrained by the physical memory on your server. In addition to fast access,
IMDB provides a simple and standard ADO/
OLEDB interface and transaction support.

Alan after having given a presentation on COM in


Switzerland (Swiss PB User Group Meeting in Zurich,
November 1998)

Page 11

DEVELOPING JAGUAR BUSINESS COMPONENTS


by Sean Flynn

Introduction
In the previous two issues of PowerTimes we have
demonstrated a sample application working in Client/Server, Distributed PowerBuilder and COM/
MTS modes of operation. In this issue we use the
same sample application with the Jaguar component
transaction manager that is part of Sybase Enterprise Application Server (EAServer). In addition to
demonstrating a PowerBuilder client accessing a
Jaguar component, we will also look at accessing
Jaguar components from other environments including as a COM object from Microsoft Active Server
Pages (ASP).

provide an extremely compelling package for developing distributed applications, especially when the
development tool used is PowerBuilder.
Jaguar Server
PowerBuilder

Business
Component

Java
C/C++

Business
Component

COM

Jaguar Overview

Figure 1, Jaguar Component Reuse.

Jaguar, from a product feature standpoint, is very


similar to Microsoft Transaction Server (MTS). It
provides an environment for deploying middle-tier
logic of distributed component-based applications.
From a PowerBuilder perspective it can host NonVisual Objects (NVOs) as components within the
Jaguar server which are then accessible by a wide
variety of client applications. Jaguar also provides
features such as transaction management, component instance pooling (down to a method invocation
level) and database connection pooling. These features provide a robust and scalable environment for
hosting components. Sybase has a number of white
papers and working examples on their developer
web site (www.sybase.com/sdn). Please refer to this
site to get additional information on Jaguar.

Why Use Jaguar?


Jaguar allows the reuse of components, at a binary
level, across many environments including PowerBuilder, Java, C/C++ and COM. By supporting
these additional environments Jaguar provides a
much broader support as compared to MTS. Jaguar
runs on NT and UNIX which allows for much
greater scalability. Jaguar also hosts PowerBuilder
runtime natively, which facilitates tighter integration with the PowerBuilder development environment including the ability to support remote debugging of components, component deployment from
within the development environment and a single
vendor for product support. Together these features

COM Component Update


In the last issue we discussed the generation of
COM components using the OLE Generation Registration Wizard and the COM Component Generator. In that issue I mentioned that I had encountered
a problem when building a project with the COM
Generator in which the object parser, during the
component compilation, gets into a recursive loop
whenever an ancestor object has references to descendent objects. In recent testing with PowerBuilder 7.0 I noticed the generator no longer GPFs, as
it did in 6.X, but instead now reports an error. This
is a problem for frameworks which frequently implement such behaviour including Rivertons OpenFrame. To resolve this issue, I developed a new
business
component
ancestor
object
(n_cst_bso_component) that removes the traditional
framework ancestry and at the same time provides
the same method interfaces normally available
through the ancestry. By switching the sample application business component ancestor from
n_cst_bso to this new ancestor, I was able to eliminate the recursive errors previously encountered
within the component generators.

Not All Good News


Although I eliminated the recursion errors during

Page 12

(Continued on page 13)

(Continued from page 12)

the COM Component Generator build, I still encountered other errors. The errors were caused by
methods that have arguments with unsupported
datatypes (e.g. any). Ironically the Jaguar Component Generator simply displays a warning message
stating that the offending methods will not be supported on the component and continues with the
generation. Unfortunately the COM Component
Generator generates errors and stops the build.
Hopefully this will be fixed in a future release (read
please fix this!). To work around this issue I created
a wrapper NVO (n_cst_bso_order_component) that
only contains the public methods necessary for the
distributed COM component. Finally I was able to
successfully build using both the COM Component
Generator and the Jaguar Component Generator.
I ran into an additional issue when attempting to
access the COM component from ASP. I traced this
down to a compilation switch in the COM project
that controls how reference arguments are passed to
methods. The switch is called Reference Arguments as Variants which is located on the
Objects tab within the Properties dialog for the
COM/MTS Component Generator project. When
this switch is turned off the PowerBuilder client can
successfully call the COM component, however, the
ASP client cannot. When this switch is turned on
the ASP client works but the PowerBuilder client
does not. Hopefully I will have more information on
this issue and the others that I encountered by the
time I give my presentation at the TechWave conference in Orlando.

Jaguar Component Generation


PowerBuilder 7.0 has introduced many new wizards
for object creation, including several for generating
Jaguar components. Since the business component
already exists as an NVO in the sample application,
I selected the Jaguar Component wizard to create
the new project. The wizard prompts for relevant
information such as the name of the component,
libraries to be used and how the component will be
deployed within the Jaguar server. The generated
project not only handles the component compilation, but also handles the deployment of the component directly into the Jaguar server.

Proxy Object Generation


In the previous article to invoke a remote COM
component we used an object with the same name
as our business component (n_cst_bso_order) whose
base type was OLE Object. By simply moving the
PBL (COM.PBL) in which this object exists higher

in our library search path we were able to invoke the


remote COM component without changing any of
the code in the client application. In order to access
the remote business component in Jaguar we need
to create a proxy object that has the same name as
our business component. By placing this library
(JAGUAR.PBL) earlier in our client library search
path we can invoke the remote Jaguar component
without having to change our client code.
PowerBuilder 7.0 makes the generation of client
side proxy objects as easy with the Jaguar Proxy
Wizard. The wizard automatically connects to a
Jaguar server allowing you to select either an individual component or an entire package of components
from which to generate proxy objects. Note that the
proxy objects must be re-generated whenever the
interface (e.g. public methods and instance variables) of the component on the server is changed.

Component Invocation
Invoking a Jaguar component is exactly the same as
invoking a Distributed PowerBuilder component,
and since the sample application was developed
from the beginning as a distributed application we
do not have to change any of the client code. All we
have to do is simply change the appropriate INI file
settings to point to the Jaguar server. The Driver
value in the INI file is set to Jaguar and the
Application value is set to the name of the package
(order) in which the component was installed in
Jaguar. Additionally a user-id and password must
also be specified. This facilitates the implementation of role based security within the Jaguar server
independent of the database, network and operating
system security.

Sample Application
As with the other articles in this series, the sample
application is a simple order/entry system based
upon the PowerBuilder Demo database. The only
difference this time is that I used PowerBuilder 7.0
as opposed to 6.x in the previous examples. I have
included a new library (JAGUAR.PBL) that contains the Jaguar proxy object for the business component.

Building the Component


As noted earlier, the component generation is as
simple as opening the Jaguar project (p_order_jag)
and selecting the Build icon. After compilation
completes the component is automatically installed
within Jaguar. Next the proxy object needs to be

Page 13

(Continued on page 14)

(Continued from page 13)

generated for the client application and the library


search path needs to be changed to include the
proxy library (JAGUAR.PBL) before the component
library (SERVER.PBL). Finally references to the
component object in the client application need to
be regenerated. For our example this can be accomplished by simply regenerating the sheet window
(w_order).

Running the Sample Application


The sample application should behave the same as
it did in the previous article examples with the only
difference being that the business component is now
being hosted within Jaguar. We can monitor the
component activity by invoking the Jaguar Manager. After connecting to the Jaguar server it provides a large number of ways to view server activity
including monitoring components, database
connections and network activity. Select the
Runtime Monitoring node to see the current activity.
Client

Server
Proxy

Client
App

Jaguar

COM
CORBA

IIOP

Component
Component

Figure 2, Jaguar COM Proxy Object.

Summary
Sybase has made significant gains in the area of
distributed application support with the release of
EAStudio and EAServer. Not only do these products provide a robust and open environment, they
also make it extremely easy to build distributed
applications. This allows organisations to leverage
existing skills sets while at the same time creating a
component environment that dramatically increases
object reuse. This is becoming more important as
companies build Internet applications that need to
share the same components that internal systems
use.

TechWave 99
Once again Im plugging my session that I will be
presenting at TechWave 99 in Orlando. The session number is AD251 and will be presented at 3:30
rd
on Monday August 23 . The session will include
many of same topics I have covered in this article
series including architecture and design issues for
distributed applications and the various technological solutions that are available. Topics include application partitioning, object set management, business rule implementation, data access abstraction
and transaction state management. Distributed implementation tech-nologies covered include JaguarCTS and Microsoft Transaction Server. Web
application servers will also be demonstrated including Microsoft Active Server Pages. The presentation runs long, so plan on staying late if you want to
ask questions.

Jaguar Component Access


As noted earlier, Jaguar allows access from a number of client environments including COM. We can
take advantage of this with the ASP example from
the last article to access our business component in
Jaguar. Jaguar supports COM access from clients by
installing a client side COM proxy object. The
proxy object translates COM calls on the client
machine into standard CORBA calls that are used
to invoke the remote Jaguar component. The COM
registration file for the client machine is generated
from the Jaguar Manager. By highlighting the
package and selecting the Generate TLB/REG
menu item the corresponding type library and registry files are created. After installing the registry
file on a client machine it can then access the
remote Jaguar component as a COM component.
We can now use the ASP example from the previous article in the same way it was used with MTS.

?
Sean Flynn is a Managing Partner at Infinity
Systems Group, a Boston area consulting and
training company specialising in distributed
systems design and development. Sean was the
principal developer of the Riverton OpenFrame
distributed business object framework. Sean is a
CPD Professional, member of the CPD Review
Committee and sits on the PowerBuilder Customer
Advisory Board. Sean can be reached at
[email protected] or by voice at 001-978287-5332.

Page 14

CYRANO ClientPack
Comprehensive Automated Software Quality
solution for PowerBuilder developments
Key Features of CYRANO ClientPack
Delivers a complete suite of integrated tools for managing and control-

ling quality in PowerBuilder development


Provides the only tool for defining and maintaining standards in
PowerBuilder applications
Optimizes development, simplifies maintenance and checks compliance to standards in PowerBuilder applications
Offers the industrys leading MS Windows multiplatform test planning, and defect tracking tool set
Integrates all of the key components needed for building and running
automated regression test suites.
Analyzes in detail the API and SQL calls of the transactions in PC based client/server
applications
Identifies where changes are needed in a PowerBuilder regression test suite as your application is
updated, developed and maintained.
Measures how much of a PowerBuilder applications functionality and objects are being tested.

Key Benefits of CYRANO ClientPack


Allows development teams to start working on building quality much sooner
than would be possible with more traditional development methods
Provides an almost instant return on investment without the need for
extensive product or methodology training
Improves communication between team members saving expensive travel

and meeting costs discussing routine project progress


Simplifies the maintenance of PowerBuilder applications and regressions
test suites
Accelerates and secures migration to latest versions of PowerBuilder
Shortens the PowerBuilder development learning curve
CYRANO Worldwide Headquarters
38, rue du Gnral Foy
75008 PARIS
Tl : +33 (0) 1 44 90 85 70
Fax : +33 (0) 1 44 90 85 79

http://www.cyrano.com
Page 15

MIGRATING APPLICATIONS FROM DISTRIBUTED POWERBUILDER TO


ENTERPRISE APPLICATION SERVER 3.0
By William B. Heys

Introduction
Recently I migrated a large Distributed PowerBuilder 6.5 application to PowerBuilder 7.0 and Enterprise Application Server 3.0. Having tried, in the
previous versions of PowerBuilder, to use Jaguar
CTS, I was pleasantly surprised by how easily one
can now deploy PowerBuilder components to EAS,
and how smooth the migration process can be.
Nevertheless, there are some significant architectural differences between DPB and EAS. Many of the
difficulties we encountered during migration could
have been minimized if we had known more about
these differences before we started.
I have even learned some things I wish I had
applied when we developed the original DPB architecture. The purpose of this article is to describe
many of the issues and challenges we confronted
during this process, in the hopes you are able to
have an easier and successful migration.

Important migration issues

Unfortunately, most distributed applications tend to


take an all-or-nothing approach towards deploying
business objects remotely. All business rules are
deployed on an application server while the client
application simply has a proxy for the remote object.
In our architecture, business objects are implemented in pairs. For each remote business object, there
is a local business object paired with it. The local
business object contains the proxy for its associated
remote business object.
When the client application instantiates a business
object on the client, this local object instantiates its
associated remote object. This architecture allows
us to deploy a particular business rule either remotely or locally. We can choose to deploy any given
business rule on the most appropriate platform
based on goals of minimizing network traffic and
maximizing performance.
The client application is not aware of where a
business rule is deployed; it only invokes methods
in the local business object. The local business
object may implement the business rule or it may
redirect a message through the proxy to the remote
business object where a business rule is deployed.

Designing a flexible architecture


Replacing server push with client pull
Instance poling
New custom class events
Stateless vs. stateful components
Database connection caches
Using global variables
PowerBuilder connection object
PowerBuilder objects as datatypes
Using PowerBuilders Any datatype
Passing null values
Benefits of Encapsulation

Replacing Server Push with Client Pull


When Distributed PowerBuilder (DPB) was first
introduced with PowerBuilder 5.0, it was not possible to implement asynchronous communication between the client application and remote objects running on the server. With DPB 6.0, this major
shortcoming was addressed using server push.

Designing a Flexible Architecture


Most PowerBuilder applications I have seen are not
well partitioned. A well-partitioned application separates business rules into business objects. By
moving business rules out of window events and
functions into business objects, you are well positioned to deploy these objects on a remote application
server such as Distributed PowerBuilder (DPB) or
Sybase Enterprise Application Server (EAS), formerly known as Jaguar.

With server push, the client application can post


(rather than trigger) a method (function or event)
on a remote object. Because the request is posted,
the client application can continue processing while
the remote object processes the request.
The client application may or may not require
notification when the remote object finishes proces-

Page 16

(Continued on page 17)

(Continued from page 16)

sing a request. If a response is needed, the client


application passes a reference to a locally instantiated business object custom class to the remote object. The remote object can post a response message
back to the local business object. The local business
object can, in turn, pass this response to the appropriate window.
As we migrated our application from DPB to EAS,
we learned server push would no longer work. EAS
components cannot post messages back to a client
application. With our architecture, changing from
server push to client pull was fairly easy and
straightforward.
To implement client pull, you must instantiate local
business objects in separate threads on the client.
You do this by creating these objects on the client
using the SharedObjectRegister() and SharedObjectGet() system functions. Shared objects run in
separate threads on the client. It is not necessary to
have a distributed application in order to have
shared objects or multi-threaded applications.
Since our architecture already creates local business
objects on the client, we only need to change how
the application instantiates them. We also changed
the client application so it communicates asynchronously with the local shared business objects. The
local business objects communicate synchronously
with remote objects on the EAS server.
Unfortunately, you cannot pass window references
to business objects running in separate threads. You
can pass custom classes but you cannot pass system
classes or visual objects to methods of an object
running in a separate thread.
Our solution was to build a "notify" object on the
client to act as a mediator between a client window
and a local business object running in a separate
thread. Before calling a method in the local business object, a window must first create a notify
object and register itself to it. The window calls a
register method in the notify object, passing a reference to the window (itself) and the name of an
event in the window to be called when a response is
received from the server. The notify object saves the
reference to its client window in a variable of type
PowerObject, and saves the windows notify" event
in a string variable.
After registering itself with the notify object, a
client window can post a method on the local
business object, passing a reference to the notify

object as an argument. The local business object


saves this reference to the notify object and communicates synchronously with the remote object. When
the remote objects finishes processing a request, it
returns control to the local business object.
The local business object calls a "notify" method on
the notify object. Next, the notify object notifies its
invoking window by dynamically posting a message
to the notify event passed to it by the window.
We designed our architecture to be very flexible.
The notify object we designed can mediate communications between disparate object types (visual and
non-visual objects). Since it uses a variable of type
PowerObject to reference its "owning" or
"invoking" client object, it can be used with any
type of object, not simply windows. In addition,
since the notify object uses dynamic messaging, it
can post different responses back to its owner based
upon context.
In summary, with server push, client windows communicate synchronously with local business objects,
and these local business objects communicate asynchronously with remote business objects on the
server. Messages are posted back and forth allowing
both the client and the server to continue processing
simultaneously without waiting on each other.
On the other hand, with client push, client windows
communicate asynchronously with business objects
running in separate threads on the client, and these
local business objects communicate synchronously
with remote business objects on the server.
Unfortunately, we did not know about client pull
when we designed the DPB application, so we used
server push. Client pull works well for both DPB
and EAS. If we had known about client pull and the
inability of EAS to use server push, we would have
designed the DPB application to use client pull; and
migrating this application to EAS would have been
far simpler and quicker.

Instance Pooling
EAS supports instance pooling of components,
where component instances can be kept in a pool
and reused without being created and destroyed
with each use. Support for instance pooling can be
set separately for individual components.
If an EAS component supports instance pooling,
once it is constructed, is kept in the instance pool

Page 17

(Continued on page 18)

(Continued from page 17)

and made available for reuse. A pooled component


remains in the instance pool and will not be destroyed until the EAS server is shut down. When a
client application creates a proxy for an EAS component, EAS will only create a new instance of the
component if there isnt one available in the pool
for reuse. Otherwise, EAS simply activates an instance from the pool.
The life cycle of an EAS component instance begins
when it is created and ends when it is destroyed. If
a component does not support instance pooling, it
must be created and destroyed with each use. Once
constructed, a pooled instance, however, may be
continuously reused, simply being activated with
each use. When not being used, a pooled instance is
deactivated and returned to the pool.
Instance pooling can significantly improve the performance of an EAS application by dramatically
reducing the number of components being created
and destroyed.

New Custom Class Events


To support instance pooling, PowerBuilder 7.0 introduces three new custom class system events.
These events (and their associated event ids) are
activate (pbm_component_activate), deactivate
(pbm_component_deactivate), and can be pooled
(pbm_component_canbepooled).
The activate event is invoked by PowerBuilder following the constructor event when a component is
initially created. For pooled components, the activate event is also invoked each time an instance is
taken from the pool to be reused.
A client application releases a remote component by
destroying the client-side proxy for the component.
For pooled components, the deactivate event is
invoked when the component is released back to the
instance pool. The constructor event is invoked only
once when the component is initially created; and
the destructor event may not be invoked until the
EAS server is shut down.
To support instance pooling, you will want to move
code from a components constructor event to the
new activate event, and from the destructor event to
the new deactivate event.
Instance pool support is a property of an EAS
component. With pooling enabled, a component
instance is always pooled after each client use. The
canbepooled event is only triggered for compo-

nents where instance pooling is not enabled. The


canbepooled event is returns a boolean, true if the
instance can be pooled, and false if the instance
cannot be pooled.
If you are migrating an application or component
from PowerBuilder 6.5 to PowerBuilder 7, you will
need to add these three new events to all existing
components. When you build new EAS components
using the wizards in PowerBuilder 7, these events
will be defined for you automatically.

Stateless vs. Stateful Components


With DPB and traditional client/server, people do
not give much thought to the benefits of stateless
components. Almost everyone uses stateful components. In our DPB application, our components
were stateful although they didn't have to be.
A stateful component is one which maintains state
for a specific client between method invocations. A
stateless component can be released following each
method invocation. Stateless components tend to be
preferred because they enable increased scalability.
In my experience, stateless components are a new
and often difficult concept for many developers to
grasp. Even I tended to design most components in
traditional client/server and Distributed PowerBuilder applications to be stateful. With a stateful component a client application might call a method to
retrieve and save the results of a query in a DataStore. Subsequently the client may invoke a different method to return all or some of the contents of
the DataStore. Since the component needs to keep
the contents of the DataStore between method invocations, it is a stateful component.
When a component is stateless, it can be reused
immediately after each method invocation. By enabling auto demarcation, a pooled component can be
released back to the instance pool without requiring
the client application to explicitly release it.
Stateless, pooled components are much more
reusable resulting in higher performance and greater scalability with fewer physical component instances being created. This also makes it easier to
take advantage of clustered servers and their failover protection. If a component does not remember
any state, it is not important what server is used the
next time a client calls a method on the component.
In addition, the component wont lose its state if a
server goes down.

Page 18

(Continued on page 19)

(Continued from page 18)

If we had designed our components to be stateless


where possible, migration from DPB to EAS would
have been quicker. We changed the architecture to
use stateless components after starting the migration. The moral of the story is, only design a
component to be stateful if you need to.

Database Connection Caches


Database connection caches help minimize performance penalties when components frequently
connect and disconnect from databases. EAS database connection caches are more robust than the
transaction-pooling feature of DPB. We chose to use
the Cache by Name feature to simplify the process
of connecting to the database from an EAS component.

certain connection properties are used.


The Driver property in DPB specifies the protocol
used for connecting to a DPB server (e.g. Winsock
or NamedPipes). In EAS the Driver property is set
to Jaguar).
The Location property in DPB points to the IP
address or host name of the DPB server. In EAS,
the Location property supports clustering servers
(for load balancing and failover). Here you can
specify a list of EAS server names and ports separated by semicolons.
The Application property in DPB specifies the
service name or port the DPB server listens to. In
EAS, the Application property specifies the
package name used by default when creating components.

The Database Connection Cache is set up using the


Jaguar Manager that is now part of SQL Central. In
a future column, I will introduce you to Jaguar
Manager and describe the process of setting up
Database connection caches.

The Options property is used to specify Object


Request Broker (ORB) options to be used. All ORB
options start with ORB, all others options are ignored.

Using Global Variables

UserID and Password are used by EAS when


creating component instances.

When I first started using Distributed PowerBuilder, I was under the mistaken impression that only
the server application could have an application
object and that individual DPB client sessions running on the server did not. For this reason I believed
it was impossible to use global variables within
remote client sessions.
Subsequently, I discovered that each client session
has a copy of the DPB servers application object
created for it, although the open and close events
are never triggered. All server-side objects created
within the client session have access to this application object and can reference its global variables.
For this reason you can declare your own global
variables or use the default global variables such as
the SQLCA transaction object within your DPB
server components.

The ConnectionString and Trace properties are


not currently used in EAS.

PowerBuilder Objects as Datatypes


In EAS, public instance variables, as well as arguments and return values used in public events or
functions must be valid CORBA data types. You
cannot use a PowerBuilder system class (such as
DataStore or window) where a CORBA data type is
required. You can pass simple data types and structures between components.
PowerBuilder custom class NVOs may be passed
between EAS components as long as they have also
been deployed as an EAS component.

Using PowerBuilders Any Datatype


In EAS, each component instance runs in its own
PowerBuilder VM session. Therefore, global variables cannot be shared by multiple client sessions
or even component instances created within a single
client session. Global variables can still be used,
however, within a component.

The PowerBuilder any type is unique to PowerBuilder and cannot be used as the datatype for an
argument or return value for any public method of
an EAS component. CORBA does in fact have an
any datatype, but EAS does not currently support it.

Passing NULL values

PowerBuilder Connection Object


The same connection object used to connect to a
DPB server can also be used to connect to an EAS
server. There are, however, several changes to how

Unlike PowerBuilder, CORBA does not directly


support null values for simple data types such as

Page 19

(Continued on page 20)

(Continued from page 19)

string or integer. PowerBuilder does, however,


have a technique for communicating null values
between clients and remote EAS components.
If a components method requires propagation of
null values, PowerBuilder will add an additional
nullflags argument to the method of the component
when it is deployed to EAS. In addition, the method
name undergoes a change (called name mangling)
such that the method name will end in __N.
The nullflags parameter is a CORBA unbounded
array (sequence) of booleans. It becomes the last
argument in the method, passed by reference
(inout). By turning individual nullflags on or off,
one component can communicate to another component which of the associated arguments contain
null values.

Benefits of Encapsulation

lumns, I will describe when and how to use other


important features of EAS such as shared and service components, database connection caches, remote debugging, using Jaguar Manager to configure
and monitor the operation of EAS, and much more.

?
Bill Heys (CPD, CPI) is a Senior Consultant at
Whittman-Hart, Inc. in Lexington, MA. Bill will
be speaking at the Sybase TechWave conference in
Orlando and at the Swiss Sybase and PowerBuilder
User Group meeting in Zurich on October 21. You
may write Bill at [email protected].

I have long advocated carefully encapsulating all


objects. This means you should never have public
instance variables, and only make methods public if
they need to be accessed by other objects. If a
method is only called internally, make the method
private or protected. Encapsulation results in the
narrowest and simplest public interface for an object.
Careful encapsulation simplified the effort for migrating our application to EAS. When you deploy a
component to EAS, its public interface must comply
with standard CORBA Interface Definition Language (IDL). Most of our component methods were
already private or protected and therefore not impacted by this constraint. This is an example where
practicing what I preach (carefully encapsulate your
objects and simplify the public interface) paid back
benefits in real life.

Bill Heys, one of the speakers at the Swiss PB


Conference 97 in Lugano, Switzerland and one of his
youngest admirers (below), Ryan Lansing, son of the
co-editor of PowerTimes, Mark Lansing.

I would encourage everyone to become aware of the


limitations of CORBA. By conforming to its requirements in future development, you won't end up
with components or methods that cannot be deployed to EAS in the future.

Summary
In this article I have tried to describe some of the
important issues you will need to understand when
you migrate a Distributed PowerBuilder application
to use Enterprise Application Server. In future co-

Page 20

DATASTORE UPDATE PROBLEM AND SOLUTION


by Gene Steiker and Alan Staub

Introduction
The following discussion analyses database update
failures in dynamically generated datastores and
DataWindow objects. Powerbuilder documentation
regarding similar issues is reviewed and a fix is
proposed that corrects the problem.

Problem Description
The update problems discussed below were encountered during development of an application window
designed to correct data entry errors in a critical
data field, the employee ID number, contained in a
range of database tables. The authors chose to use
dynamically created datastore and DataWindow objects for this purpose in order to minimise the
maintenance required to accommodate future changes to database tables and the addition of new
tables.
The application was built using Powerbuilder 5.0.04
and PFC. The application serves as a front end for
a DB2 database.
The window functions by querying the database
system tables to identify tables containing the subject columns and then creating a datastore dynamically for each relevant table to implement updates.
DataWindow objects were also generated dynamically for each datastore using SyntaxFromSQL()
and Create() functions.
Initial tests of this window resulted in erratic update
failures. Upon execution, the PB update() function
returned errors (return value of 1) for 10 of 43
tables in which changes were applied. However,
following implementation of the fix outlined below,
all 43 tables were successfully updated using the
dynamic datastores.

store containing a dynamically generated DataWindow object. The user noted that this problem occurred when tables had defaults associated with at least
one column. This case involved an application built
with PB 5.0.02, going against a MS SQL Server
database.
To resolve this issue, the PB Technical Personnel
advised the user to list specific column names when
building DataWindows on the fly, instead of employing the wild card character, e.g.:
SELECT column_1, column_2,
FROM

instead of
SELECT *
FROM

However, application of this technique did not correct the update problems in our case. Update failures continued regardless of which form of SQL was
used.

Analysis
The update failures were investigated further by
examining SQL syntax issued to the database. A
messagebox was placed in the datastore's SQLPreview event for this purpose.
This revealed two problems. First, in cases where
updates were failing, the update SQL statements
generated by the DataWindow objects did not contain key columns for the relevant tables in the
WHERE clauses. This occurred despite specification of option 2 for the DataWindow's
Table.UpdateWhere property requiring use of all
key and modified columns.

PB Documentation

In other words, the DataWindow issued the following type of SQL string for updates:

A similar case may be found in the Powerbuilder


Technical Bulletin (see Issue 457498, opened
7/29/97, closed 10/24/97).

UPDATE target_table
SET modified_column = 0002
WHERE modified_column = 0001

In the reported case, both the Retrieve() and Update() functions failed (returned 1) against a data-

instead of

Page 21

(Continued on page 22)

(Continued from page 21)


//* Datastore DBError Event
il_sqldbcode = sqldbcode
return 1

UPDATE target_table
SET modified_column = 0002
WHERE key_column = XXX
AND modified_column = 0001

Second, the messagebox placed in the datastore


SQLPreview event appeared twice for unsuccessful
updates. When this occurred, an error code of 100
was returned in the datastores DBError event from
the second update with the following error message:
No data was found to satisfy the request.
It was surmised that the database table was modified successfully by the first SQL statement. However, failures were caused when the same SQL statement was issued to the database a second time and
the modified table no longer contained records that
matched the update statements WHERE clause.
This conclusion was verified by the success of the
solution outlined below.
Additional insights were gained by building DataWindow objects manually for the database tables
generating failed updates. In these cases, it was not
possible to set DataWindow update properties without first specifying key columns manually. The
DataWindow was apparently unable to query the
database successfully to identify the key fields. This
lack of database communication explains why references to key columns are absent from the SQL
update syntax issued by some of the dynamically
generated DataWindow objects.

Solution
The update failures were corrected by adding code
in the datastores DBError event and at the point in
the main window where updates are executed. This
code avoids interruption of processing when the
double update bug occurs.
It should be noted that in our application every
update was preceded by a retrieve. It was therefore
certain that database records corres-ponding to the
WHERE clause in the SQL UPDATE statement
existed in all cases, so that the double update bug
was the only possible reason for an update to return
an error code of 100. This may not be true for other
applications.

Before issuing an update, the datastore instance


variable containing the database error code was
initialised to avoid confusion when successive
updates were implemented. Then the error code
returned from the datastore was examined following execution of the Update() function.
An error code of 100 returned from the database indicated an occurrence of the double update bug. When this was detected, the 1 error
code returned from the Update() function, representing a failed update, was reset to 1 and
processing was continued.
//************************************
//* Main window function:
//* wf_modify_datastore_records
//************************************
//* Initialise Error Code
ids_table_change[ll_i].il_sqldbcode = 0
//* Execute Update
li_ret = ids_table_change[ll_i].Update()
//* Ignore Update Bug
IF ids_table_change[ll_i].il_sqldbcode &
= 100 THEN
li_ret = 1
END IF

Conclusion
The preceding article describes datastore update
failures that occur sporadically with dynamically
generated DataWindow objects. It appears this is
caused by the DataWindow objects inability to
identify key columns for certain database tables. In
such cases, the DataWindow generates an error
code of 100 when it sends the update SQL statements to the database a second time.
A fix is outlined for this problem that is effective
but less than optimal. The authors would be interested in learning whether other developers have
encountered similar problems and, if so, what techniques were employed to resolve the issue. In addition, since this problem occurred using Powerbuilder Version 5.0.04, we are curious to know whether
subsequent versions of Powerbuilder also include
the double update bug.

The following specific steps were implemented:


An instance variable was defined in the subject
datastore and code was added to the datastores
DBError event to capture database error codes.
(Continued on page 23)

Page 22

(Continued from page 22)

?
Gene Steiker is the principal of GDS Associates and is currently Project Leader for a PowerBuilder/
Oracle project at a large university. Previously, Gene has worked on Powerbuilder applications for
corporations in the financial services, telecommunications electronics, and health services fields. Gene
can be reached at [email protected] .

Alan Staub is a Senior Programmer/Analyst with Salomon Smith Barney currently working on
applications utilizing Powerbuilder and DB2. His previous experience includes development of
Powerbuilder applications at various firms utilizing a variety of databases. Alan can be reached at
[email protected].

Are you living in or around Switzerland and looking for


training on Use Case Analysis with HOW ?

Stop searching...
Course:
Date:
Location:

Use Case Analysis with HOW


September 10 - 11, 1999 and September 13 - 14, 1999
Zurich, Switzerland

More information available at: http://www.raksoft.ch or e-mail: [email protected]


Course organised by RAKSoft in collaboration with KVL IT Solution Providers, Netherlands

RAK Software, Consulting & Publishing


Rolf Andr Klaedtke
Bchlistrasse 21
CH-8280 Kreuzlingen / Switzerland
Phone:
Fax:
Internet:

+41-71-670 01 60
+41-71-670 01 71
http://www.raksoft.ch

Sybase System Integrator - IBM Business Circle Partner - Riverton Software: HOW Partner

Page 23

a Client/Server and Internet development and consulting company

7RROV
&OLHQW6HUYHU

'HYHORSPHQW
- Custom made Software in any Business
Area

,QWHUQHW

(QWHUSULVH, 1HW

'HYHORSPHQW
- Custom made Web Sites
+ Easy to maintain
+ Fast Development
+ Public Hosting available

'HYHORSPHQW
- Custom made Web
Sites for Intranet and
Internet usage

7UDLQLQJ
- For Sybase AG and 5HVDOH
- ColdFusion
SQL AG
- HomeSite
- ScriptBuilder
&RQVXOWLQJ
- On various PowerBuilder Topics

6\EDVH&$33DUWQHU

&ROG)XVLRQ5HVHOOHU

5HVDOH
- SilverStream Reseller

6LOYHU6WUHDP9$5

Catsoft Development GmbH, Amdenerstr. 28a, CH-8872 Weesen


Tel: ++41 55 616 51 11, Fax ++41 616 51 14
Web: www.catsoft.ch, E-Mail: [email protected], Compuserve: CATsoftCH

3DJH

MULTI-SELECT TREEVIEW
by Boris Gasin and Roy Kiesler

Introduction
As I frequent the newsgroups and mailing lists one
of the treeview-related questions comes up over and
over. How do I enable multiple selection in the
treeview? Unfortunately, by design , the PowerBuilder Treeview control does not support multiple
selection. Or does it? This months column will
revolve around the treeview control, specifically the
ability to provide multiple item selection.

environment was no exception. The library painter


treeview in PowerBuilder 5 and 6 was also a
simulated treeview. See Figure 2.

The Requirement
The idea of a multiple selection in a navigation
control may seem strange to some. After all, the
treeview was intended for navigation. This can be
seen in the standard Explorer interface. See Figure
1 below. If you need selection, well thats what the
listview is for.

Figure 2, PowerBuilder 6.0 Library Painter


The Poweruilder 6 library painter offers a perfect
example of the dual purpose treeview. While the
treeview is used for navigation, it also offers object
selection to be copied, deleted, checked out from the
source control, or processed in some other manner.
It is this metaphor, familiar to all the PowerBuilder
developers, that often leads to the multi-select treeview requirement.

Figure 1, Windows Explorer Interface


However, when it comes to GUI standards, things
are never black and white. The standards themselves are often subjective and are in a constant state of
flux. Prior to version 5 of PowerBuilder, many
developers and popular class libraries emulated the
treeview with a DataWindow control. Multi-row
selection was often supported in the DataWindow
based treeviews. The PowerBuilder development

Could there be valid reasons to allow multiple


selection in a treeview? Whenever there is little
need to manipulate the items at the lowest level it
seems to be a waste to add another control just to
allow selection. Why duplicate the data?
The multi-select treeview examples above come
from simulated treeviews and may not be considered real authentic standards. How about Microsoft?
Well, even they have strayed a little from the original stance on the treeview item selection standard.
Take a close look at the Internet Explorer and the
(Continued on page 26)

Page 25

(Continued from page 25)

Active Desktop options window. The advanced tab


displays a control similar to a treeview, but at the
lowest level there are checkboxes and radio buttons
allowing single and multiple item selection. See
below.

not be desirable. The ideal case would be to toggle


the item selection only when the state picture is
clicked. Clicking on the state picture should not
cause the item focus to change. How can this be
done? The treeview does not have a StatePictureClicked event. Fortunately there is always a
workaround

Figure 3, IE Options Window Treeview


Now here is an idea. If we cant accomplish multiple selection by highlighting the treeview items,
how about adding a checkbox or a radio button state
picture to flag the selected items? This interface is
the best of both worlds. The highlighted item still
provides indication of navigation, while checkboxes
emulate multiple selection. We can use a checkbox
or radio button bitmap in the state picture to indicate selection. The finished product is shown in
Figure 4.

Making it Work
The biggest implementation challenge has to do
with the selection of the tree view items. Specifically, choosing the correct event to select the checkbox. The checkbox or the radio button picture
should be toggled when it is clicked. If item selection is performed from the treeview clicked event,
the checkbox or a radio button would be toggled,
but the item state picture will also be toggled when
the treeview is clicked anywhere on the item. A
second problem is that there is no way to select an
item from the clicked event without causing the
focus to change to the new item. The Option Tree
treeview provides two distinct functions navigation and selection. Mixing these two functions and
causing the selection to affect the navigation would

Figure 4, Multi-Select Treeview


The solution is to set a boolean indicator whenever
a mouse pointer is over the state picture. In the
clicked event we can check the boolean instance
variable and only process clicks on the state picture.
To determine whether the pointer is over the state
image we will rely on a TVM_HITTEST message.
The message determines the location of the specified point relative to the client area of a tree view
control. It is used along with an argument structure
TVHITTESTINFO.
FUNCTION long HitMsg( long hWindow, uint
uMsg, long wParam, REF OS_TVHITTESTINFO
lParam ) LIBRARY "user32.dll" ALIAS FOR
SendMessageA

Listing 1, SendMessage API Call


After the message is triggered and the x, y location
are provided, the TVHITTESTINFO structure is
populated with the information specifying the location relative to a tree view control. The location
flags are shown in Table 1 below.

Page 26

(Continued on page 27)

(Continued from page 26)


TVHT_ABOVE
TVHT_BELOW
TVHT_NOWHERE
TVHT_ONITEM

TVHT_ONITEMBUTTON
TVHT_ONITEMICON
TVHT_ONITEMINDENT

TVHT_ONITEMLABEL

TVHT_ONITEMRIGHT
TVHT_ONITEMSTATEICON

TVHT_TOLEFT
TVHT_TORIGHT

Above the client area.


Below the client area.
In the client area, but
below the last item.
On the bitmap or label associated with an
item.
On the button associated with an item.
On the bitmap associated with an item.
In the indentation associated with an
item.
On the label (string)
associated with an
item.
In the area to the
right of an item.
On the state icon for
a tree view item that
is in a user-defined
state.
To the left of the client area.
To the right of the
client area.

Table 1, Treeview Location Flags


The
flag
of
interest
to
us
is
TVHT_ONITEMSTATEICON. Below is the code
from the mousemove event.
OS_TVHITTESTINFO lstr_tvhittest
// Get the pointer location.
lstr_tvhittest.str_pt.l_x = UnitsToPixels(
xpos, XUnitsToPixels! )
lstr_tvhittest.str_pt.l_y = UnitsToPixels(
ypos, YUnitsToPixels! )
// Send message to retrieve handle to
// item pointed by mouse.
HitMsg( il_handle, TVM_HITTEST, 0,
lstr_tvhittest )

After the selection problem is solved, the rest of the


implementation involves a few functions traversing
the treeview and performing the requested action. A
sample application along with the source code mentioned in this article can be downloaded from the
resources section of the PowerTimes website.

Using the Object


Using the Option Treeview is pretty straightforward. Object functions allow the selection of a
single item and a group of items. They also provide
access to selected item handles, labels or data. Most
of the functions are overloaded to take action on the
whole treeview or items under a specified tree
branch.
of_SelectAll - Selects all tree view items under a
specified root item.
of_DeSelectAll - De-selects all tree view items
under a specified root item.
of_IsSelected - Returns TRUE if a specified tree
view item is selected.
of_GetSelectedItems - Returns an array of handles/
labels/data for all selected items under a specified
root item.
of_SelectItem - Toggles the selection state of a
specified tree view item. For radio button items, all
sibling items are toggled as well to ensure mutually
exclusive selection.
Code samples for some of the above functions are
provided below.
Integer li_rc
li_rc = tv_1.of_SelectAll()

Listing 3, Selecting all items in a treeview


Long ll_root, ll_child
Integer li_rc
ll_root = tv_1.FindItem(&
RootTreeItem!, 0 )
IF ll_root > 0 THEN
ll_child = tv_1.FindItem(&
ChildTreeItem!, ll_root )
END IF
li_rc = tv_1.of_SelectAll( ll_child )

// Set the flag if we are over a state


// checkbox.
IF lstr_tvhittest.l_hItem <> 0 THEN
ib_stateclick = &
(lstr_tvhittest.l_flags = &
TVHT_ONITEMSTATEICON )
END IF

Listing 4, Selecting all items under a


specified root item

Listing 2, Using TVM_HITTEST


This approach can be utilised in any situation when
you need to determine the specific pointer position.

Page 27

(Continued on page 28)

(Continued from page 27)


Long ll_root, ll_child
Integer li_rc
String ls_labels[]
ll_root = tv_1.FindItem(&
RootTreeItem!, 0 )
IF ll_root > 0 THEN
ll_child = tv_1.FindItem(&
ChildTreeItem!, ll_root )
END IF
li_rc = tv_1.of_GetSelectedItems(
ll_child,& ls_labels )

Roy Kiesler is a Senior Consultant at Noblestar


Systems Corporation. He has been working with
PowerBuilder since version 4.0, developing client/
server applications for the pharmaceutical,
financial and communications industries, using
PowerBuilder, C++ and MFC.
Roy is a member of Team Sybase - an elite group of
technically proficient Powersoft product users who
volunteer their time to answer questions in various
support forums. He can be reached via email at
[email protected]. For a picture of Roy,
please see on page 7.

Listing 5, Getting all text labels of selected


treeview items under a specified root

Conclusion
In this article we have demonstrated a PFC based
implementation of a multiple-selection/option
treeview control. The code and examples shown in
the article were kept simple to demonstrate the
techniques involved. If you are going to implement
this in your extension to PFC, you might want to
consider moving it into a Treeview service.
While the utilisation of the new metaphor is
straightforward, the real question is when should
this approach be used instead of a more traditional
treeview / listview or treeview / DataWindow combination approach? As previously mentioned, the
main purpose of the treeview control is to provide
hierarchical navigation. However, there are cases
when the last treeview level represents some data.
This data level, as well as operations the application users will need to perform on this data, determine which approach is more appropriate. If the
data needs to be presented in a number of different
ways, if it needs to be sorted, filtered, or processed
in some other way then stick with a listview or a
DataWindow approach. If multiple selection is required and data itself does not require a complex
presentation, the Option Treeview may be a good
candidate.

Boris Gasin is a Chief


Technology Officer at
Dynamic
Technology
Group, a New Jersey based
consulting
company
specialising in Internet and
Client-Server technologies.
Boris is a president of New
Jersey PowerBuilder User
group http://www.njpbug.org/, a member of
Team Sybase and a three time winner of the Team
MVP award. Boris is a co-author of PowerBuilder
Foundation Class Professional Reference
published by McGraw-Hill, ISBN # 0-07-913267-7
and a contributing author of the PowerBuilder 6.0
Secrets of the Masters by SYS-Con Publishing.
He
can
be
reached
via
email
at
[email protected].

Page 28

Tool
of the
m o nt h

Client-Server

Datenbanken

Services

PowerBuilder 7

The good news is, the skills youve already learned


will make you successful as you pursue new
opportunities on the Internet. PowerBuilder 7.0 is
designed to take you to the next phase of your
development career, with all the power and
capability that has made PowerBuilder the number
one choice for serious business application
development year after year.

The bridge from


client/server to Web
and distributed
applications

PowerGen

PowerDoc

The essential tool for


generating PB
applications.

Get your self some


extra sparetime.

PowerGen's breakthrough
technology gives you
unprecedented flexibility and
speed when you building
PowerBuilder applications.
Recreate your libraries (PBLs)
from object source. Use
PowerGen to produce all your
PowerBuilder deliverables in a
single step.

Am Borsigturm 48
D-13507 Berlin
Germany
Phone: +49 (0)30 430 323 50
Fax: +49 (0)30 430 323 55
Email: [email protected]

PowerDoc automates the


entire process of generating
high quality, technical
documentation. With simple,
easy-to-understand
instructions, you select the
PowerBuilder application to
document, and PowerDoc
does the rest, including the
preparation of Table of
Contents and Index.

PB Spy

ImagN

Get an inner sight


of whats going on
in your PB 6.5
Application.

Show what youve


got.

More than a debugger. The


service-based TreeView and
ListView controls are now PB
Spy objects with Message
Pump and other features. Justin-time debugging has been
built into the Message Service
and the Action Menu so that
you can break into the source
code.

The family of ImagNtoolkits


takes the headache out of
integrating graphics images into
your Windows applications!
Display BMP, PCX, DCX, GIF,
JPEG, Progressiv JPEG, PIC,
Targa, and TIFF images using
ImagNs powerful 16 & 32-bit
engines.
Super FAST viewing and print
engine available as an ActiveX
or DLL/VCL.

Page 29

'SHARE' THE GLOBALS


by Jon Credit

Introduction
Ever since I can remember I have heard the same
thing regarding global variables DON'T USE
THEM! Everywhere I have been it's the same story,
"don't use global variables global variables are
bad ". During technical interviews I have been
told repeatedly that global variables are really bad.
We all seem to agree that global variables are not
good, but it still seems that they make their way into
applications. I can't remember the last architecture
I saw that did not use a global variable of some type.
Even the PFC, which is touted for its object oriented
design, abuses the rule of no global variables. This
article will discuss a technique that will allow you
to eliminate the use of global variables in your
application code once and for all.

Why Developers Use Globals


Global variables are used when a variable has to be
available to multiple modules of an application.
Everyone knows global variables are bad design but
they are still used. Some common responses in
defense of using global variables are:
Well, we only have one global variable
There is no other way around it
I need this variable in multiple places in the
application
It makes the code easier to read
Global variables can make developing an application easier, but they can cause nightmares when the
application is actually deployed. The big problem
with global variables is that they are fully accessible
(i.e. can be read and written to) from anywhere in
an application. It is possible for modules of an
application to test fine during unit testing and then
not work at all when the end user first gets the
application (been there and done that!). The reason
this happens is because the user does not use the
application the way the developer thought they
would, and the global variables are most likely not
properly initialised.
There is no way to verify or enforce that global
variables are properly initialised when entering a
module of code. It is not possible to restrict a part of
an application from modifying the contents of a

global variable while another part of the application


is currently using that variable.

Mis-Behaving Globals
Niki is a senior developer on a project and has a
particular result set that she needs to share in
multiple windows throughout her application. She
decides to create a global DataStore to hold this data
and then she uses the ShareData function to share
the data with her windows that require the data.
Holli is a newer developer on the team and has a
similar requirement to share a common set of data
in multiple places in the application. She takes the
same approach as Niki and creates another global
DataStore variable to cache DataWindow data. After developing a few modules using the DataWindow caching technique, Holli notices that rows
could be added to, or removed from, the table
during the running of the application. She decides
to add an embedded SQL call to count the number
of rows currently in the table and compare that with
the rowcount in the global DataStore just prior to
the ShareData call. If the number of rows currently
in the table and the DataStore rowcount are not the
same she re-retrieves the DataStore before calling
ShareData.
Niki notices what Holli is doing and thinks this
would be good logic to add to the modules that she
has already developed. She makes code changes to
all the modules she has written that use the DataWindow caching technique.
Other developers on the team that have been using
global DataStores for DataWindow caching notice
the actual rows in their result sets may also change
during the running of the application. They decide
to add embedded SQL to compare the current number of rows in the database with the DataStore row
count.
Just prior to deploying the application the developers find out there is a data model change being
implemented that is going to affect the SQL of all
the global DataStores that have been created for
their application. Not only does the SQL for each of

Page 30

(Continued on page 31)

(Continued from page 30)

the DataStores need to be modified, but also the


embedded SQL used to retrieve the current rowcount in the table needs to be modified. The DataWindows that actually display the data do not need
to be modified because the result set does not
change (number of columns and data types). However, the developers still need to make changes to
every window that uses the DataStore caching technique in order to modify the embedded SQL.
The above is an example of how global access to
variables can cause problems in an application. The
DataStores are being accessed directly and there is
no controlling interface to protect developers when
business rules change.

What are Shared Variables?


Shared variables (not to be confused with Shared
Objects) are one of the most misunderstood variables in the PowerBuilder language. I have met
many PowerBuilder developers over the years and I
only know of a handful that use Shared Variables or
fully understand the benefit of using them. Shared
variables have been available to us since PowerBuilder 1.0, so this isn't any new ground breaking
technology. The shared variable is analogous to the
class (or static) variable in C++ and the static field
in Java. They are variables that have the same value
for all instances of a class and do not lose their
value when the last instance of the class is destroyed. A shared variable placed on an ancestor
object maintains a common value for all descendent
objects. There is one catch to using Shared variables
in PowerBuilder: they are private in nature. This
means that any descendant objects cannot directly
access or write to the shared variable. Read access
can be easily accomplished with a 'Get' method on
the ancestor object, and write ability can be provided via a 'Set' method on the ancestor object.
Consider the following simple example:
Create an NVO, say n_count, with a single shared
variable of type Integer
// Shared Variables
Integer si_count = 0
// Constructor Event
si_count = si_count + 1
// Method nf_howManyTimes
String ls_count
ls_count = String(si_count)
MessageBox( "This class has been instantiated", ls_count + " times" )

Create a window with a command button that contains the following script:

// We are going to display how many times


// this script was called
n_count lnv_count
lnv_count = Create n_count
lnv_count.nf_howManyTimes()
Destroy lnv_count

Each time the button is clicked, a MessageBox will


be displayed displaying the value of si_count. The
value of si_count is incremented in the constructor
event of n_count so the incremented value is being
displayed in the MessageBox call. The first time the
button is clicked the MessageBox in figure 1 is
displayed. The second time the button is clicked the
MessageBox in figure 2 is displayed. Each subsequent click of the button will increase the value of
si_count and the new value is displayed in the
MessageBox call.

Figure 1, First time n_count instantiated

Figure 2, Second time n_count instantiated


When you first look at the above code you may be
thinking that since the NVO was destroyed and it
was local to the button script, there is NO WAY
that the MessageBox shows an incrementing number. Remember, we said that Shared Variables have
the same value for all instances of the class and do
not loose their value when the last instance of the
class is destroyed. Shared variables maintain their
value for the life of the application, not the object
instance.

'Share' the Solution


Using the DataWindow-caching example from before, we can change the implementation of the
global DataStores to be Shared Variables within a
Non Visual Object (NVO). In order to implement

Page 31

(Continued on page 32)

(Continued from page 31)

this approach we need to create an NVO that


contains the following:
A shared variable to hold the DataStore
Code to initially setup and retrieve the DataStore
nf_share method to share the data in the DataStore with a passed in DataWindow
The best approach to sharing the data is to pass a
DataWindow into the function and issue the ShareData call within the NVO function. This hides the
implementation of how the DataWindow is actually
populated and prevents objects outside the NVO
from being able to manipulate the DataStore.
The NVO would look something like this:
// Shared Variables
DataStore sds_NikisStuff
//
//
//
If

Constructor Event
Check to see if the DataStore has
been initially created
NOT IsValid(sds_NikisStuff) Then
sds_NikisStuff = Create DataStore
sds_NikisStuff.dataObject = "d_niki"
sds_NikiStuff.SetTransObject(SQLCA)
sds_NikisStuff.Retrieve()
End If

have doubts, put a MessageBox call inside the IF


condition in the constructor event.)
The above example demonstrates how Shared Variables can be used to replace global variables in
application code. In the above code, we can also
easily adapt if we ever need to add retrieval arguments to the DataStore. Another benefit that is
achieved from using the Shared Variable approach
is the NVOs that contain the Shared Variables are
reusable with other applications; global variables
are not reusable across applications.

Conclusion
By using Shared Variables instead of global variables, the options are open to the developer when
change occurs. This article discussed the usage of
Shared Variables to replace global variables but it
also touched on the topic of working with components. We did not have to put the shared Variable in
an NVO; we could have placed it on a window. If
we had encapsulated the Shared Variable on a
window, however, we most likely would not be able
to freely reuse the functionality within a single
application, let alone start thinking of reusing it in
other applications.

// method nf_share(REF DataWindow adw_1)


Long ll_currentRows
// Get the # of
Select count(*)
:ll_currentRows
<condition that

rows
INTO
FROM <table> WHERE
matches DataStore>

Jon Credit is the Vice


President of Technical
Consulting for CLM
Concepts, a regional
consulting
company
specialising in Internet and
Client/Server technologies.
Jon is a member of Team
Powersoft,
CPD
Professional,
and
a
member of the CPD
Certification Committee. You can visit Jon's web
site,
Credit's
Corner
at
http://
jcredit.home.sprynet.com or send him an e-mail
directly at [email protected].

If ll_currentRows &
<> sds_NikisStuff.RowCount() Then
Sds_NikisStuff.Retrieve()
End If
// Share the data
Return(sds_NikisStuff.ShareData(adw_1))
// Application open event
// Setup DataWindow cache
n_NikiCache lnv_cache
lnv_cache = Create n_NikiCache
// Everything is setupdestroy
Destroy lnv_cache
// Open event of window that requires
// the DataWindow cache
n_NikiCache lnv_cache
lnv_cache = Create n_NikiCache
lnv_cache.nf_share(dw_1)
// No longer need the NVO
Destroy lnv_cache

People who don't understand how Shared Variables


work get very confused when they see a call to
Create and Destroy on successive lines in the application open event script. We know the IF statement
in the constructor event will only evaluate to true
the first time this NVO is instantiated. (If you still

Page 32

ENCRYPTX 3.1
by InnerDynamics Software
Reviewed by Arthur Hefti

Introduction
Do you have applications that exchange data with
other applications but you cant use database replication? Do you use text files for this data exchange?
Do you ever worry about size and security, e.g.
everybody can see whats in these files? Well, EncryptX, by InnerDynamics Software, can handle all
these problems for you. It is an ActiveX that can
encrypt and compress your output.

Description
EncryptX uses the BLOWFISH Cipher to encrypt
the data. This method was designed by Bruce
Schneier who is a well-known expert in the field of
encryption. Mr. Schneier is also the author of the
excellent book Applied Cryptography, Second Edition, (John Wiley and Sons, 1996) which gives the
complete code and description of BLOWFISH as
well as that for most of the other encryption algorithms in use today.

Technically BLOWFISH is a 16 pass block encryption method that works in blocks of eight bytes.
During each pass the bits are shuffled in a pattern
that is different for each locking key. After 16
passes the bits appear completely randomized. However, the seemingly random bytes can be recovered by rerunning the algorithm with the same
encryption key
BLOWFISH is a symmetric block cipher that takes
a variable-length key, from 32 bits to 448 bits.
BLOWFISH was designed in 1993 by Bruce
Schneier as a fast, free alternative to existing encryption algorithms. Since then it has been analyzed
considerably, and it is slowly gaining acceptance as
a strong encryption algorithm. BLOWFISH is unpatented and license-free, and is available free for all
uses.
To compress the data EncryptX uses C-CADE, a

(Continued on page 34)

Page 33

(Continued from page 33)

proprietary multi-pass compression block derivative


that dynamically compresses each phase of the
BLOWFISH cipher stream as it's produced. The
encrypted and compressed files are only slightly
larger than having them zipped without encryption.

Usage
The ActiveX comes with 5 functions: One for switching the component from trial to full mode, two to
encrypt and decrypt files and two to encrypt and
decrypt strings.
Once the EncryptX ActiveX is installed and registered on your machine, you can insert the control on
the window or user object you need to encrypt/
decrypt.
The usage of the encryption functions is quite simple.

The decryption functions are called FileDecrypt and


DataDecrypt and have the same arguments.

Conclusion
EncryptX is an easy to use and powerful ActiveX
that gives your applications the possibility to use
encryption and compressions within a few minutes.

Pricing and Availability


The price ranges from US$ 79 for an individual
copy up to US$ 450 for an unlimited developer
license. EncryptX is available from:
InnerDynamics Software
1264 King Carey Drive
St. Louis, MO. 63146
USA
http://www.innerdynamics.com.

lb_Result=ole_crypt.Object.FileEncrypt( &
<InFile>, <OutFile>, <password> )
ls_Crypt=ole_crypt.object.DataEncrypt( &
<InText>, <password> )

Advertiser Index
Page

Name

Internet address

5
9
15
23
24
29
35
44

Sybase, Inc.
E. Crane Computing
Cyrano
RAK Software, Consulting & Publishing
CATsoft Development GmbH
PowerPeople
SYAP AG
SybSearch

www.sybase.com
www.ecrane.com
www.cyrano.com
www.raksoft.ch
www.catsoft.ch
www.powerpeople.de
www.syap.ch
www.sybsearch.com

Page 34

For More Information Fax back this reply, or call our sales team.

Phone: 041 760 5071

Fax: 041 760 1707

Name
Company
Function

Department

Phone

Fax

E-Mail
SYAP AG, Dorfstrasse 38, Baar CH-6340.
Phone: 041 760 5072 Fax: 041 760 1707 Web Site: www.syap.ch

Page 35

PowerTimes provides this space to the subscribing


user groups to publish their news, announcements
and other communications to their members. Please
send your material to the editor or the co-editor of
PowerTimes (addresses under Impressum).

If your user group doesnt subscribe to PowerTimes


yet, please contact us to get the very reasonable
rates or check out our web site at:

http://www.powertimes.com

Baltimore PowerBuilder User Group


The Baltimore Area PowerBuilder Users Group
(BAPBUG) meets the first
Wednesday of the even numbered months at the Social Security Administration OAG
building in Woodlawn, Maryland.

The members of the Baltimore PowerBuilder User


Group receive PowerTimes thanks to a generous
sponsorship from

http://www.geocities.com/SiliconValley/Bay/8680

http://www.ctpartners.com

President:

Debbie Arczynski
[email protected]

Vice President:

Bill Bitman
[email protected]

Secretary:

Gordon Giffen
[email protected]

Treasurer:

Fred Grau
[email protected]

Specializing in the Sybase, SilverStream and


Microsoft families of products, Corporate Technology Partners offers a full line of client/server and
web application development and training services.
Point your browser to http://www.ctpartners.com/
asp/tips.asp for frequently updated, cutting edge
whitepapers, and a variety of helpful, technical tips
from industry pros. Visit today to see how we can
help your organization realize the most effective
emerging technology solution.

Web Administrator: Anne Sola


[email protected]
Newsletter Editor:

Greg Dzingeleski
[email protected]

Calgary PowerBuilder User Group


The President of the Calgary PowerBuilder User
Group, Todd Costella, can be reached at the
following e-mail address:
[email protected]
The members of the Calgary PowerBuilder User
Group receive PowerTimes thanks to a generous
sponsorship from aRenDeeco, Inc.

Page 36

Greater Boston PowerBuilder Users Group


The officers of the User Group are:
President:

Dan Murphy

Vice President:

Olga I. Demidova
[email protected]

Treasurer:

Karen Ness
[email protected]

Secretary:

Susan Thompson
[email protected]

KEVSystems is a PowerSoft Consulting Partner


and provides system design and integration assistance for financial, personnel, and medical systems.

The members of the Greater Boston PowerBuilder


User Group receive PowerTimes thanks to a generous sponsorship from KEVSystems Inc., located
in Newton, MA.

Our staff, made up exclusively of Certified PowerBuilder Developers, has over 20 years experience
in securities processing systems and database design. We have worked on systems for trust accounting, shop floor management, personnel, and threetiered integration.
KEV Systems, Inc.
65 Stony Brae Rd.
Newton, MA. 02161-1728
Phone:
Fax:

(617) 964 1426 or (800) 376 5755


(617) 527 0090

ChicagoLand PowerBuilder User Group


The officers of the CPBUG are:
President
Vice-President
Secretary
Treasurer

Michael Baraz
Peter Vassilatos
Jeff Barnes
Nicky Petrila

The CPBUG website can be found at:


(630) 235-4529
(312) 856-6720
(847) 549-7765
(630) 792-5073

http://www.cpbug.org
The Secretary of the ChicagoLand PowerBuilder
User Group, Jeff Barnes, can be reached at the
following e-mail address: [email protected].

Central Ohio PowerBuilder User Group


The Central Ohio PowerBuilder Users Group generally meets during the second week of odd numbered months. Meetings alternate between member
demos and product presentations.
Location:

Vince Fabro
[email protected]
614 - 220 7900

Vice President:

Jeff Kusner
[email protected]
614 - 213 5329

Secretary:

Jim Nelson
[email protected]
614 - 418 1748

Treasurer:

Todd Dake
[email protected]
614 - 418 1748

Bank One Offices


1111 Schrock Road, Columbus, OH

Refreshments: 6:00 - 6:15pm, Presentation: 6:15


Our mailing address is:
Central Ohio PowerBuilder User Group
P.O. Box 363
Worthington, OH 43085-0363
Internet:

President:

http://www.cmhpbug.com

Page 37

Club Fibonacci - Club des Utilisateurs Sybase France


Le club francais des utilisateurs PowerBuilder n'existe plus en France. Il a t remplac par le Club
Fibonacci: le club des utilisateurs Sybase, qui est
gr directement par Sybase France.
Les membres du Club Fibonacci reoivent PowerTimes grace au sponsoring gnreux de la socit
NOVALYS.
(The PowerBuilder User Group France doesn't existe anymore. It has been replaced by the "Club
Fibonacci" - the Sybase Users Group in France
The members of the Club Fibonacci (France) receive PowerTimes thanks to a generous sponsorship from Novalys.).

NOVALYS met en place des


outils, mthodes et normes de
dveloppement pour la russite de
vos applications. Les consultants
de Novalys accompagnent et certifient vos projets
pour garantir leur russite technique.
NOVALYS creates, distributes and supports
complementary tools for PowerBuilder and is the
distributor of HOW from Riverton Software in
France.
Visit our website at: http://www.novalys.fr.
Novalys SA
140 rue Gallini
92100 Boulogne-Billancourt / France
Tel : 01.46.99.66.20

Fax: 01.46.99.08.92

PowerBuilder User Group Denmark


The members of the PowerBuilder User Group
Denmark receive PowerTimes thanks to a
generous sponsorship from Sybase Denmark.

E-mail:
Tel:
Fax:
Internet:

[email protected]
+45 6313-6128
+45 6313-6199
http://www.sybase.dk/pbusgdk

New Jersey PowerBuilder User Group


The President of the New Jersey PowerBuilder
User Group, Guy Yasika, can be reached at the
following e-mail address: [email protected]
Dynamic Technology Group, Inc.
1055 Parsippany Blvd., Suite 501-26
Parsippany, NJ 07054

The NJPBUG website can be found at:

http://www.njpbug.org

Phone:
Fax:
The members of the New Jersey PowerBuilder User
Group receive PowerTimes thanks to a generous
sponsorship from Dynamic Technology Group.

Page 38

973.402.5600
973.402.5620

http://www.dynamictechgroup.com

PowerBuilder User Group Germany e.V.


Das nchste Meeting der PBUGG findet am 18. und
19. Oktober 1999 in Stuttgart statt. Es knnen noch
Vortrge gemeldet werden. Auch Anregungen
werden noch entgegen genommen.
Am 18.10.99 findet unsere Vereinsversammlung
mit Wahl des Vorstands statt. Einladungen werden
rechtzeitig verschickt.
Viele Gre
Ludwin Feiten (Vorstand)
E-mail:
[email protected]

Besuchen Sie die Homepage


der PowerBuilder User Group
Germany:
http://www.pbugg.de
PBUGG e.V.
c/o Power People
Ludwin Feiten
Am Borsigturm 48
D-13507 Berlin
Tel.:
+49 (0)30 4303 2350
Fax:
+49 (0)30 4303 2355

Houston PowerBuilder User Group


The members of the Houston PowerBuilder User
Group receive PowerTimes thanks to a generous
sponsorship from Dynamic Data Solutions, Inc.

President:

Vice President:

Rick Pal
[email protected]

Ken Frohne
[email protected]

Conference Coordinator:

Ron Francis
[email protected]

Treasurer:

Nonie Cody
[email protected]

Secretary:

Ram Raman
[email protected]

Newsletter Editor:

Randeep Takkar
[email protected]

http://www.dyn-data.com
Dynamic Data Solutions provides expert application development consulting in the areas of traditional and web client/server focusing on integrated
solutions from the Sybase/Powersoft and Microsoft
families of products.
Come check our Tech Zone at http://www.dyndata.com/ims/techzone/techzone.stm for a searchable database of development tips as well as real
world examples of our expertise at work.

Madison PowerBuilder User Group


President:

Eric Larson
(608)252-3385

Vice President:
Treasurer:
Secretary:
Webmaster:

Amy Jo Esser
Craig Cole
Bruce Meister
Jeffrey White

Internet:

Page 39

http://www.madpug.org

Indianapolis PowerBuilder User Group


The User Group meets on the 3rd Thursday of every
even month.
President:

Deanna Townsend
[email protected]

VP:

Scott Cunningham
[email protected]

Secretary:

Angie Kemerly
[email protected]

Treasurer:

Bruce Kohl
[email protected]

The members of the Indianapolis PowerBuilder


User Group receive PowerTimes thanks to a generous sponsorship from

Since 1993, Fortune 1000 companies have looked


to Client Server Associates (CSA) for solutions to
their business computing needs. Offering software
products for purchase, consulting services and
comprehensive and customized education programs, CSA is a single source provider and partner
throughout the Midwest with offices in Cincinnati,
Columbus and Indianapolis.

Webmaster: [email protected]
Internet:
http://www.ipbug.org

Northwest PowerBuilder User Group


Meetings are generally scheduled once every other
month.

The members of the NorthWest PowerBuilder User


Group receive PowerTimes thanks to a generous
sponsorship from ServerLogic Corporation.

The Northwest PB User Group URL is:

http://www.cascadia-sw.com/nwpbug/
The NWPBUG officers are:
President:

Anirban Choudhury
[email protected]

Vice President:

Paul Gibson
[email protected]

Secretary:

Anil Batra
[email protected]

Treasurer:

Connie Butler
[email protected]

http: //www.serverlogic.com

Feel free to get in touch with us through our web


site for more meeting info... we look forward to
hearing from you ! PBUG's can be fun (well at
least informative, trust us) !!

ServerLogic Corporation is a premier provider of


corporate software development and information
technology consulting. ServerLogic has worked with
hundreds of organizations throughout the US, Canada, and the world seeking effective consulting,
tool, and training solutions. Successful application
development or migration of legacy applications to
more productive client/server or internet environments requires expertise in design, development,
testing, and implementation. ServerLogic has the
experience to help ensure your success in these areas.

Page 40

PowerBuilder User Group Norway


presenterer sine lsninger, tredjepartsleverandrer
presenterer sine produkter, konsulenter viser prosjekter de har deltatt i etc.

Formlet med brukerforeningen er todelt:


1. Den skal vre et kompetanseskapende forum
for brukere av Powersoft-produktene
(PowerBuilder, PowerJ, Power++, PowerDesigner, Enterprise Application Server).

Blant aktivitetene i foreningen nevner vi:


Egne tekniske kvelder
Bttur
Julebord
Norsk / Nordisk brukerkonferanse

2. Den skal vre et kontaktpunkt mellom brukerne og Sybase Norge, nr det gjelder forslag til endringer/forbedringer av produkter
og relaterte tjenester.

Bde btturen og julebordet er gode anledninger for


knytte faglige og sosiale kontakter i bransjen. Selv
Brukerforeningen er uavhengig av Sybase Norge, og om disse arrangementene i frste rekke er sosiale,
har et styre p seks medlemmer som er valgt p starter vi med et faglig innhold som innledning til
foreningens generalforsamling. De fleste arrange- kvelden. rets bttur er planlagt til tirsdag 15. Juni.
menter i brukergruppens regi foregr p kveldstid.
Arrangementene tar sikte p at man skal kunne nsker du mer informasjon kan du ta kontakt med
utveksle erfaringer og kunnskap gjennom at brukere noen i styret.
Thomas Revetal
Stig Melling
Rune Nerhagen
Wenche Fronth
ystein Rolfsen
Leif Aksel Grthe
Mona Eng

EDB ASA
Avenir ASA
WM-Data
Hrens Forsynings Kommando
De Norske Bokklubbene
OCP AS
Sybase Norge AS

Tlf. 22 72 80 00
Tlf. 23 15 75 00
Tlf. 22 57 70 00
Tlf. 23 09 63 86
Tlf. 22 02 20 00
Tlf. 23 10 55 16

Ottawa PowerBuilder User Group


The Ottawa PowerBuilder User's Group is
composed of Ottawa-area Information Systems professionals who are interested in
staying on the leading edge of PowerBuilder and client/server development.

President:

Carole Hargrave
[email protected]

The group meets on the 2nd Wednesday of each


month, from September through May. At each
meeting, a new and interesting topic is presented
and discussion is encouraged. These meetings are a
great place to meet fellow users, discuss issues and
ideas, and network for future opportunities.

VP Administration: Bill Stevens


[email protected]

VP Public Relations: Mike Woods


[email protected]

Treasurer:

Mark Jorgensen
[email protected]

Secretary:

Pauline Aubertin
[email protected]

The Ottawa PowerBuilder User Group website can


be found at http://www.opbug.com

Page 41

St. Louis PowerBuilder User Group


We meet on the 3rd Tuesday of every other month,
beginning in January at Monsanto Corporate
Headquarters (directions on the web page). The
meetings begin at 5:30 pm.
Solutech is a company specializing in client/server,
web application development, technical training,
vendor certified consulting and software solutions.

The new website is http://www.stlpbug.org

President:

Jay Hunt
[email protected]

Vice President:

Allen Phelps
[email protected]

Secretary:

Neal Bockwoldt
[email protected]

Treasurer:

Solutech maintains strategic partnerships with leading software vendors such as Microsoft, Oracle,
Rational, Powersoft and Sybase. These partnerships
give you a direct link to new product information
and on-going technology developments. Solutech is
a local extension of our vendors, bringing you peace
of mind in a constantly changing environment.

Dave Blankenship
[email protected]

The members of the St. Louis PowerBuilder User


Group receive PowerTimes thanks to a generous
sponsorship from Solutech, Inc. in St. Louis.

Solutech has nine offices and training centers. For a


complete list of our free seminars and vendor certified training classes; or to view the latest company
information on Solutech, our locations, and our
services, please visit us on the web at
www.solutechinc.com.

UK PowerBuilder User Group


An independent group formed
in 1992, PBUG currently has a
membership approaching 150
companies. Events are held
three times each year with
attendances in the region of
200 at each event. The group
is self-funding and receives
excellent technical support from Sybase.
PBUG Council:
Chairman:

Warren Clayburn
[email protected]

Treasurer:

Ian Soden
[email protected]

Secretary:

David Speight
[email protected]

Member:

Brick Du Bourg
[email protected]

The member council runs PBUG, but the day-to-day


work is managed by Pb Associates.
Anne Bocock is responsible for most aspects of the
group including organising the conferences and
putting together PBulletin. Judy Barnett handles all
accounting matters. You can reach Anne and Judy
at the PBUG office.
Telephone:
Fax:
Email:
Internet:

0181 421 3533


0181 420 1420
[email protected]
http://www.pbug.co.uk

Postal address:
Suite A8, Kebbell House
Carpenders Park
Watford, Herts. WD1 5BE

Page 42

PowerBuilder User Group Italia


Anche quest'anno possiamo contare su Sybase e il
suo nuovo Powerbuilder 7, cogliamo l'occasione
per augurare un buon SMAU 99.

E-mail: [email protected]
Fax:
0331/700189
Internet: http://www.telemacus.it/pbug/pbug.htm
L' abbonamento a PowerTimes per gli iscritti del
Power Builder User Group Italia e' stato gentilmente offerto da Sybase Italia.

The members of the PowerBuilder User Group


Italy receive PowerTimes thanks to a generous
sponsorship from Sybase Italia.

Sybase and PowerBuilder User Group Switzerland

CATsoft
Dear SPBUGS Member,
The Swiss PowerBuilder User Group and the Sybase
User Group Switzerland have merged to become the
Sybase and PowerBuilder User Group Switzerland.
Our first joint meeting (the 5th annual meeting of the
PowerBuilder section) will take place in Zurich on
October 21st. The main speaker will be Bill Heys, check
out the web page at http://www.spbug.ch for more
details.
As our president is resigning after 5 years we are
currently looking for new steering committee members.
If you are interested please contact the Secretary Mrs
Celia Hegarty by mailing her at [email protected].

CATsoft Development GmbH is a Swiss Client/


Server and Internet/Intranet company specializing
on PowerBuilder and JAVA development. We
have experience in PowerBuilder on the Internet
(Web.PB), Powersoft's PFC and HOW. We also do
Cold Fusion and SilverStream.
CATsoft Development GmbH
Amdenerstrasse 28a
CH-8872 Weesen
Phone:
Fax:
Web:

We hope to see you in October.


The SPBUGS Steering Committee

The members of the SPBUG receive PowerTimes thanks


to a generous sponsorship from CATsoft Development
GmbH in Weesen.

Page 43

+41-55-616 51 11
+41-55-616 51 14
www.catsoft.ch

Page 44

You might also like